Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: K_2KPosted on 2003-10-06 at 11:22:48ID: 9499956
Two or more possibilities:
You could isolate bat2 as is and have batch1 run itself through a filter into batch2. I've got a demo of that here somewhere, . . .
Or you could use ^ to escape the special characters, like you did with ^< in the FOR /F to get < into the IN (' ... ' )
This gets prticularly messy when escaping the ^ itself with ^^ as well as the < after it though.
Have you considered using CALL to a label instead? Any time you CALL a label it acts as if the currently running program is a new program starting at that label
Good Luck,
2K
(\o/)
::batch1.bat
:: do some stuff
:menu
:: tell user what's going on
echo.
echo Whanna erase some of the file, eh?
echo.
set /P zans=Whatta you wanna delete?
if "%zans%"=="last line" CALL :BATCH2
:: If batch2 runs, when done we will be back here
if "%zans%"=="first line" CALL :BATCH3
:: If batch3 runs, when done we will be back here
if "%zans%"=="all" CALL :BATCH4
:: If batch4 runs, when done we will be back here
if "%zans%"=="quit" GOTO :EOF
goto :menu
:: safety line to prevent BATCH2 from running accidentally
goto :EOF
:BATCH2
set zfn=myfile.txt
set zsp=nº50
set ztf=z
:B2_temploop
set ztf=%ztf%b
if exist %temp%\%ztf%* goto :B2_temploop
set ztf=%temp%\%ztf%
for /f "delims=[]" %%i in ('find /n "%zsp%" ^<%zfn%') do set zln=%%i
echo %zln%d>%ztf%a
echo e>>%ztf%a
edlin %zfn% <%ztf%a >nul
if exist %ztf%* del %ztf%*
for %%i in (ztf zln zfn zsp) do set %%i=
goto :eof
::END OF BATCH2 - GOTO :EOF will return to the line after CALL
:BATCH3
.
.
.
goto :eof
:BATCH4
.
.
.
goto :eof