I have a batch file which checks how many picture are in a folder. How can I return this value back to the JavaScript which calls the batch file?
dir /B /A-D /S "C:\Users\Viktor\Desktop\Images\*.jpg" | find /N /C /V ""
pause
Here is the code which runs the batch file from JavaScript:
var file = null;
var process = null;
var args = [""];
// create an nsIFile for the executable
file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
file.initWithPath("C:\\Users\\Viktor\\Desktop\\file.bat");
// create an nsIProcess
process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file);
// Launch the process
process.run(false , args, args.length);
I don't know why you need this batch file when you can use only your browser and imacros .js
Open the folder in your browser: file:///C:/Users/Viktor/Desktop/Images/
then run this .js in iMacros:
var img = new Array();
iimPlayCode("TAG POS=1 TYPE=BODY ATTR=* EXTRACT=TXT");
img = iimGetExtract().split(".jpg");
alert(img.length-1);