Reputation: 33
I have a question about a batch file that I am writing.
How can I define my "for /f" loop to execute only one part of my script and not the whole script ?
In the script below, I would like
I precise that I need to use a "call" method (because of another issue with backlash).
Thank you for your help :)
@echo off
setlocal enabledelayedexpansion
WMIC LOGICALDISK where drivetype=3 get caption>%~n0.tmp
for /f "tokens=1-3 skip=1" %%a in ('type "%~n0.tmp"') do call :displayinfo %%a
del "%~n0.tmp"
goto :eof
:displayinfo
set drive=%1
echo Le drive est %drive%
echo lancement du DIR
REM call dir /A HS /s /b %drive%\ >> d:\Dir_ALL.txt
echo Fin du DIR
:step2
echo this is the step2, to be executed when the for /F loop is over.
echo blablalblablalballbabal
:step_End
echo Ths is the end
@pause
Upvotes: 1
Views: 6259
Reputation: 20179
You need to make two changes.
goto :eof
two lines below your for
line to goto :step2
.goto :EOF
as the last line of your :displayinfo
method. This will cause the method to return to the for
loop.It should look like this.
@echo off
setlocal enabledelayedexpansion
WMIC LOGICALDISK where drivetype=3 get caption>%~n0.tmp
for /f "tokens=1-3 skip=1" %%a in ('type "%~n0.tmp"') do call :displayinfo %%a
del "%~n0.tmp"
goto :step2
:displayinfo
set drive=%1
echo Le drive est %drive%
echo lancement du DIR
REM call dir /A HS /s /b %drive%\ >> d:\Dir_ALL.txt
echo Fin du DIR
goto :EOF
:step2
echo this is the step2, to be executed when the for /F loop is over.
echo blablalblablalballbabal
:step_End
echo Ths is the end
@pause
Upvotes: 4