-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirSimple.js
More file actions
48 lines (39 loc) · 1.16 KB
/
DirSimple.js
File metadata and controls
48 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var oArg = WScript.Arguments;
var sOut = "";
var arrOut = new Array();
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
if (oArg.length == 1) {
if (oFSO.FolderExists(oArg(0))) {
ListFolderContents(oFSO.GetFolder(oArg(0)));
sOut = arrOut.join("\r\n");
//var objIE = new ActiveXObject("InternetExplorer.Application");
//objIE.Navigate("about:blank");
//objIE.document.parentWindow.clipboardData.setData("text", sOut);
//
//objIE.Quit();
// use clip.exe -- this one flashes a command window, but it screams
// Durations (ms): 3, 0, 2, 2
var WshShell = new ActiveXObject("WScript.Shell");
var oClip = WshShell.Exec("clip");
var oIn = oClip.stdIn;
oIn.Write(sOut);
oIn.Close();
WScript.Echo("Done");
}
else {
WScript.Echo("The argument must be a folder.");
}
}
else {
WScript.Echo("There must be exactly one argument.");
}
function ListFolderContents(oFolder) {
var files = new Enumerator(oFolder.Files);
for (; !files.atEnd(); files.moveNext()) {
arrOut.push(files.item().Path);
}
var folders = new Enumerator(oFolder.SubFolders);
for (; !folders.atEnd(); folders.moveNext()) {
ListFolderContents(folders.item());
}
}