我完全是个菜鸟,但我找到了这个可以满足我需求的东西。只需使用 .bat 文件备份单个文件即可。
: variables
set drive=D:\backup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
echo ### Backing up your Sites directory...
%backupcmd% "d:\example\example.txt" "%drive%\%dateNtime%"
echo Backup Complete - Your Backup is located at %drive%
问题是,当我尝试将其作为 .bat 文件运行时,它总是会出现
D:\w10>set drive=D:\backup
D:\w10>SET dateNtime="31-01-2019_16-38"
D:\w10>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
D:\w10>echo ### Backing up your Sites directory...
### Backing up your Sites directory...
D:\w10>xcopy /s /c /d /e /h /i /r /k /y "d:\example\example.txt" "D:\backup\"31-01-2019_16-38""
Does D:\backup\31-01-2019_16-38 specify a file name
or directory name on the target
(F = file, D = directory)?
我如何让它自动选择 D(或 F)?