Page 1 of 1

batch file to read a 2nd field in flatfile (dos)

Posted: 19 Jun 2012 17:29
by sabercats
I have a log file \from\where\some\directory\log.txt

Code: Select all

54,SABERCATSWIN7x64,sabercats-pc,,,2012-06-19 15:36:42.000,,,,,,,
3,SABERCATSWIN7,sabercats-pc,,,2012-06-18 15:44:53.000,,,,,,,,


How do we write dos batch file to get the hostname of the old start time (automatically in 2nd lines) like
sabercatswin7
and then run execute script C:\script\removeit.exe -release=SABERCATSWIN7

I want the batch file to run in scheduler to remove the old hostname.
Thanks,

Re: batch file to read a 2nd field in flatfile (dos)

Posted: 19 Jun 2012 17:44
by aGerman
Probably that way:

Code: Select all

for /f "usebackq skip=1 tokens=2 delims=," %%i in ("C:\from\where\some\directory\log.txt") do (
  C:\script\removeit.exe -release=%%i
)

Regards
aGerman

Re: batch file to read a 2nd field in flatfile (dos)

Posted: 20 Jun 2012 11:04
by sabercats
Thanks, it works.