@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
为什么这不起作用?我是否错误地使用变量?第一天使用命令行和批处理文件。
答案 0 :(得分:5)
您需要在=
之前删除 SPACE ,否则它将成为变量名称的一部分:
@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