Created
January 12, 2011 03:44
-
-
Save BlueSkyDetector/775660 to your computer and use it in GitHub Desktop.
このスクリプト単体で次のように実行するとC:\のファイル数が取得可能。 > cscript //Nologo files_count.js "C:\"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDirectoryFilesCount(path) { | |
var fd = new ActiveXObject("Scripting.FileSystemObject"); | |
var d; | |
var ret; | |
try { | |
d = fd.GetFolder(path); | |
ret = d.Files.Count; | |
} catch(e) { | |
ret = "-1"; | |
} | |
d = null; | |
fd = null; | |
return ret; | |
} | |
var arg = WScript.arguments; | |
if (arg.length!=1) { | |
WScript.echo("-1"); | |
} else { | |
WScript.echo(getDirectoryFilesCount(arg(0))); | |
} | |
arg = null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment