Thursday 15 April 2010

Searching and executing from a specific line in a file -



Searching and executing from a specific line in a file -

i've file publicholidays.txt, below contents (one html script in line). windows 7

a.html b.html c.html d.html

if user inputs b.html (ignoring case) batch file should start executing b.html till end of file i.e. d.html

i refereed article doesn't seems help

overview: need write batch job executes either contents specified in txt file or take user input , execute command line (basically 1st search string in file , start executing line).

@echo off echo ********************************************************************** @setlocal enableextensions enabledelayedexpansion set total=0 /f "usebackq tokens=*" %%i in (publicholidays.txt) ( set ln=%%i %%j in ("!ln!") ( /f %%k in ('echo %%j ^| find /i /c ".html"') ( @set /a total=!total!+%%k ) ) ) setlocal enabledelayedexpansion echo *************total !total! ************* echo. set /p scriptname=please come in script name : if [%scriptname%] equ [] goto scriptname /f "tokens=%scriptname% skip=%line% delims=," %%j in (publicholidays.txt) ( setlocal enabledelayedexpansion phone call specificcmd -s -i %scriptname% >> outout.txt ) pause

class="lang-dos prettyprint-override">@echo off setlocal set /p scriptname=please come in script name : /f "tokens=1*delims=." %%j in (q26519180.txt) ( if /i "%scriptname%"=="%%j" set "scriptname=" if not defined scriptname echo(call specificcmd -s -i %%j.%%k ) goto :eof

this should work you.

i used file named q26519180.txt containing info testing.

the required commands simply echoed testing purposes. after you've verified commands correct, alter echo(call call execute process files.

note i've removed redirection create testing easier.

batch-file command-line-arguments command-prompt batch-processing

No comments:

Post a Comment