Skip to content

Instantly share code, notes, and snippets.

@BlueSkyDetector
Created January 12, 2011 03:44
Show Gist options
  • Save BlueSkyDetector/775660 to your computer and use it in GitHub Desktop.
Save BlueSkyDetector/775660 to your computer and use it in GitHub Desktop.
このスクリプト単体で次のように実行するとC:\のファイル数が取得可能。 > cscript //Nologo files_count.js "C:\"
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