Srijani Ghosh
Srijani Ghosh

Reputation: 4216

XCOPY not recognized as internal or external command

I am very new to batch file coding. I am trying to use XCOPY for copying some file. First I used like this:

@echo off

MOVE mypath\abc.txt mypath\abc.txt.0001
XCOPY mypath\abc.txt.bak mypath\abc.txt

pause

This code is working perfectly fine. Then I needed to take some input from user, o I modified the code like this:

@ECHO off

ECHO Starting application.
SET /p path=Enter the path: 
SET /p corruptFileName=Enter the corrupted file name: 
SET /p oldBackupFileName=Enter the Backup file name to restore: 
SET /p correuptedBackupName=Enter the corrupted backup file name: 

ECHO Path : 
ECHO %path%
ECHO Corrupted file name : 
ECHO %corruptFileName%
ECHO Desired Backup file name:
ECHO %correuptedBackupName%
ECHO Backup file name to restore : 
ECHO %oldBackupFileName%


MOVE %path%\%corruptFileName% %path%\%correuptedBackupName%
call :waitfor 5000>nul
XCOPY %path%\%oldBackupFileName% %path%\%corruptFileName%

PAUSE

This code is not running. It says that :

The system cannot find the batch label specified - waitfor
'XCOPY' is not recognized as an internal or external command,
operable program or batch file.

Can anyone shed any light in this?

Thanks!

Upvotes: 0

Views: 3210

Answers (1)

SomethingDark
SomethingDark

Reputation: 14304

%path% is an environment variable that is used to tell the operating system where programs are located. Without it, you have to give the full path to system executables (like xcopy) before they can be called by name only.

Never overwrite it.

Change the variable name to something else. Anything else.

Upvotes: 2

Related Questions