Reputation: 247
@echo off
set /p fileToCopy = "File you want to copy: "
set /p destinationFile = "Destination file (On Desktop): "
xcopy c:\users\jordean\desktop\%fileToCopy% c:\users\jordean\desktop\%destinationFile%
pause
Why does this not work? Am I using variables incorrectly? First day using command line and batch files.
Upvotes: 3
Views: 8947
Reputation: 34979
You need to remove the SPACE before =
, otherwise it becomes part of the variable name:
@echo off
set /P fileToCopy="File you want to copy: "
set /P destinationFile="Destination file (On Desktop): "
xcopy "C:\users\jordean\desktop\%fileToCopy%" "C:\users\jordean\desktop\%destinationFile%"
pause
Upvotes: 7