Advertisement
cd62131

Substitution on BATCH (JScript)

Apr 29th, 2017
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @if (1 == 1) /*
  2. @echo off
  3. cscript //nologo //e:JScript "%~f0" %*
  4. @goto :eof
  5. */
  6. @end
  7. var arg = WScript.Arguments;
  8. if (arg.length != 1) WScript.Quit(1);
  9. var fso = new ActiveXObject("Scripting.FileSystemObject");
  10. var fin = fso.OpenTextFile(arg(0), 1);
  11. var out = WScript.StdOut;
  12. //var out = fso.CreateTextFile(arg(0) + ".new", true);
  13. var log = WScript.StdErr;
  14. //var log = fso.CreateTextFile(arg(0) + ".log", true);
  15. var no = 0;
  16. while (!fin.AtEndOfStream) {
  17.   ++no;
  18.   var line = fin.ReadLine();
  19.   if (no <= 4) {
  20.     out.Write(line + "\r\n");
  21.     continue;
  22.   }
  23.   var separate = line.split("\t");
  24.   if (separate[4] != "") {
  25.     out.Write(line + "\r\n");
  26.     continue;
  27.   }
  28.   separate[4] = "999";
  29.   out.Write(separate.join("\t") + "\r\n");
  30.   log.Write("line: " + no + ", changed.\r\n");
  31. }
  32. WScript.Quit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement