Reputation: 1038
I am trying to create a simple batch script to copy a folder to another folder.
@ECHO OFF
IF %1.==. GOTO INFORM
XCOPY %1 D:\CopyLoc /D /E /C /R /I /K /Y
ECHO Copied
GOTO EXT
:INFORM
ECHO USAGE: CUSTCP <SOURCE DIRECTORY>
:EXT
I have saved this file under the name custcp.cmd
.
When I say
C:\>custcp
I get the message The syntax of the command is incorrect.
But what I want is to display USAGE: CUSTCP <SOURCE DIRECTORY>
message. Is there any other novel way of doing this? Also I want to know if this command will work for folders in mapped network drives?
PS:This is my first attempt at batch file creation.
Upvotes: 0
Views: 598
Reputation: 79947
Since <
and >
are redirection characters, batch wonders where you want to redirect the text to.
Use a caret (^
) directly before the redirection characters to turn off their special meaning, thus:
ECHO USAGE: CUSTCP ^<SOURCE DIRECTORY^>
Upvotes: 2