Is it possible to manage files and directories (i.e. get a directory's content, create/copy/delete files, etc.) usig javascript in WSH ?
I did a quick look at MSDN and I cant find an object that let me do that.
Asked
Active
Viewed 2,934 times
2

GetFree
- 40,278
- 18
- 77
- 104
2 Answers
4
Is FileSystemObject what you're looking for?

RichieHindle
- 272,464
- 47
- 358
- 399
-
I see. However, that's not under the WSH section in the documentation. It doesn't seem to be part of the WSH DOM. – GetFree Jun 04 '09 at 08:05
-
I'm not saying it doesn't work. Just poining out that it's somewhere else in the MSDN documentation tree. – GetFree Jun 04 '09 at 08:06
-
I'm looking at it in MSDN under "Microsoft Windows Script Technologies". – RichieHindle Jun 04 '09 at 08:09
-
Yep. But I was looking under "Windows Script Host". Thanks. – GetFree Jun 04 '09 at 08:16
2
var fso = WScript.CreateObject("ScriptingFileSystemObject");
var CurDir = fs.GetFolder("C:\\temp");
var Files = CurDir.Files;
for(var fileitem = new Enumerator(Files); !fileitem.atEnd(); fileitem.moveNext())
{
fso.CopyFile(fileitem.item(), ExeDir);
}

Kevin Buchs
- 2,520
- 4
- 36
- 55
-
1First line should be "Scripting.FileSystemObject" not "ScriptingFileSystemObject" – mhenry1384 Sep 06 '12 at 15:39