Please find below a program to copy-paste the folder from one location to another. While trying to execute it I am getting the error as : ( was unexpected at this time.
@echo off
set /p SrcPath= Source file is
echo %SrcPath%
set /p DestPath= Destination file is
echo %DestPath%
echo Checking if the package with the same name exists in the Destination Path
if exist %DestPath% (
echo Folder exists
echo Do you want to rename the existing folder Y/N
set /p Answer=
echo %Answer%
if %Answer% == y ( echo please suggest what suffix you would like to append e.g. _old, _bkp etc
set /p Suffix=
move %DestPath% %DestPath%%Suffix%
goto :CopyPackage )
if %Answer% == n echo "please decide what to do"
) else ( echo "folder doesn't exist"
goto :CopyPackage)
:CopyPackage
ROBOCOPY /s /e %SrcPath% %DestPath%
Output on cmd prompt:
C:\Users\shreyash>Z:\Dev\FolderEx.bat
Source file is C:\New
C:\New
Destination file is C:\New1
C:\New1
Checking if the package with the same name exists in the Destination Path
( was unexpected at this time.
C:\Users\shreyash>Z:\Dev\FolderEx.bat
Source file is C:\New
C:\New
Destination file is C:\New1
C:\New1
Checking if the package with the same name exists in the Destination Path
( was unexpected at this time.
C:\Users\shreyash>Z:\Dev\FolderEx.bat
Source file is "C:\New"
"C:\New"
Destination file is "C:\New1"
"C:\New1"
Checking if the package with the same name exists in the Destination Path
( was unexpected at this time.
Please suggest what modifications are required!!!