computing
  • 3

Batch File Executing Twice-What Is The Issue

  • 3

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

Share

1 Answer

  1. 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.

    • 0