Solved Batch file executing twice-what is the issue

August 31, 2012 at 02:30:36
Specs: Windows XP
Hello All,
the below code will create a file in current folder with file name list-files_<current_folder>.txt
along with the actual file, a file of same content is getting created with name list-files_.txt.

what is the mistake & how to avoid it???

My code:

Call :FOLDER %CD%
:FOLDER
set MyCurDir=%~n1
set MyFile=list-files_%MyCurDir%.txt
dir /s/b *.plmxml | find /V "unstripped" > %MyFile%

Thanks a lot in Advance....

-Duddukuri


See More: Batch file executing twice-what is the issue

Report •


#1
August 31, 2012 at 03:01:13
✔ Best Answer
You call the subroutine with a parameter (%CD%). When the subroutine ends it falls through to :FOLDER and runs again, this time without a parameter.

Add a line

GOTO :EOF

after the Call line. You should also add

GOTO :EOF

at the end of the subroutine.


Report •

#2
August 31, 2012 at 03:17:10
Thanks ijack for the reply.
please add your inputs in the above code and paste as reply....

Report •

#3
August 31, 2012 at 03:21:14
Call :FOLDER %CD%
goto :EOF
:FOLDER
set MyCurDir=%~n1
set MyFile=list-files_%MyCurDir%.txt
dir /s/b *.plmxml | find /V "unstripped" > %MyFile%
goto :EOF

Report •

Related Solutions


Ask Question