DIQQUER
DIQQUER

Reputation: 15

Call a .bat file from iMacro / js

i am trying to call a batch-file from a iMacro that I created. I run a .js script, with runs several .iims and shall then execute the .bat file.

The .bat file removes the first 5 lines from a .txt file and saves it again. The .txt will be used in the next script run. - I'm using a for-loop for this -

So my question is: How can I execute this .bat file from my .js script? Would it be possible to write a code which deletes the first 5 lines of this specific .txt? (then I wouln't need the .bat)

// I am running Windows 10 and I am using Firefox

Thanks for helping me out!

Upvotes: 0

Views: 562

Answers (1)

Shugar
Shugar

Reputation: 5299

To work with a txt-file seems to be more preferable in similar cases. Try the script like this:

var fileTxt = imns.FIO.openNode("D:\\iMacros\\Datasources\\test.txt");
var lines = imns.FIO.readTextFile(fileTxt).split("\r\n").slice(5).join("\r\n");
imns.FIO.writeTextFile(fileTxt, lines);

Note: your txt-file must be in UTF-8 encoding.

Upvotes: 0

Related Questions