Skip to content

Instantly share code, notes, and snippets.

@BlueSkyDetector
Created November 21, 2011 16:34
Show Gist options
  • Save BlueSkyDetector/1383159 to your computer and use it in GitHub Desktop.
Save BlueSkyDetector/1383159 to your computer and use it in GitHub Desktop.
files count by js
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