REM Capture the date/time(right down to the second) and then assign it to a variable set yy=%date:~-4% set dd=%date:~-7,2% set mm=%date:~-10,2% set newdate=%dd%%mm%%yy%_%Time:~0,8% set newdate=%newdate::=% SET foldername="svetlana_backup_%newdate%" SET drive=T: REM Source directories SET documents=%drive%Documents REM Destination directories SET destinationDocuments=%backupDir%Documents call:makedirandcopy %documents% %destinationDocuments% :makedirandcopy ECHO Making and copying %~2 Directory MKDIR %~2 XcopY %~1 %~2 /E /F
我在桌面上有以下batch file,当我运行batch file时,它应该在目标驱动器上创build一个目录并复制所有文档,但是,它使目录和文档子目录, 但在我的桌面上,batch file所在的位置,并且从不复制文档中的文件。 文件名也是不正确的,它只是将时间分配给目录而不是date_time。
Passing T:Documents "T:Backup""svetlana_backup_23022016_ 91300"Documents Making and copying T:Backup""svetlana_backup_23022016_ 91300"Documents Directory Making and copying Directory 0 File(s) copied
如果我没有这个标签,所有这些都可以工作。
从外部文件读取variables不能按计划任务运行
有哪些选项可用于获取cron的结果以及如何设置它们?
使用for循环读取文本文件replace多行batch file
call :makedirandcopy %documents% %destinationDocuments% goto :EOF :makedirandcopy ECHO Making and copying %~2 Directory MKDIR "%~2" XcopY "%~1" "%~2" /E /F goto :EOF
从你的跑步报告中,你有一条线
Passing T:Documents "T:Backup""svetlana_backup_23022016_ 91300"Documents
你有
Making and copying T:Backup""svetlana_backup_23022016_ 91300"Documents Directory Making and copying Directory
原因是你正在call :makedirandcopy (它显示第一行),当call ed例程结束(大概到达文件结尾)控制返回到call的语句 – 这是例程再次,这次没有参数,因此第二行。
尝试
call :makedirandcopy "%documents:"=%" "%destinationDocuments:"=%" goto :EOF
这将删除每个变量中的多余的引号并且引用结果。
请注意,由于传递给:makedirandcopy的参数中有空格,因此xcopy将要求引用这些参数。
也许你也需要
... set newdate=%newdate::=% set newdate=%newdate: =0% ...
用一个真实的,真正的0代替被抑制的前导零。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。