I have created a simple batch script that only copies pdf file in the server. Copied file will be stored in a folder in desktop.
But after copying there is a "New Folder" created. Why is this happening?
this is my script :
:MENU1
set /p code=Input Folder Code:
if %code%==0 goto MENU1
goto CHECK1
:CHECK1
if exist "%sample2020%\%code%\STANDARD\DATA\PLAN\%code%WAB.pdf goto COPYFILE
if not exist else goto ERROR
:COPYFILE
xcopy "%sample2020%\%code%\STANDARD\DATA\PLAN\%code%WAB.pdf" "%HOMEPATH%\Desktop\2. FILES\%code%\DOCUMENTS\" /D /E /C /I /Y /H
start "" "%HOMEPATH%\Desktop\2. FILES\%code%\DOCUMENTS\"
goto MENU1
:ERROR
echo.
echo PK file cannot find....
PAUSE
start "" "%HOMEPATH%\Desktop\2. FILES\%code%\DOCUMENTS\"
this is the actual image of copied files ... as you can see it has a New Folder..

if /?and read the output help.if not exist else goto ERRORis not of correct syntax. It can be replaced by justgoto ERROR.if %code%==0 goto MENU1byif defined code if "%code:"=%" == "0" goto MENU1for more safety against wrong user input by mistake. See the answer on How to stop Windows command interpreter from quitting batch file execution on an incorrect user input?xcopyand that does not create aNew folder. But the batch is not a minimal, reproducible example. We don't know how the environment variablesample2020is defined and we don't know what the user of this batch file enters. Why do yo usexcopy.exeinstead of newerrobocopy.exe? Why do you usexcopyoption/D. Why do you usexcopyoption/Eto copy also empty directories if you want to copy only a PDF file. Why do you not usecopyto copy a single PDF file?/Dand/E.