Robocopy显示无效参数 [英] Robocopy showing invalid parameter

查看:317
本文介绍了Robocopy显示无效参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的学院制作备份程序,但显示的robocopy副本

I am making a backup programme for my institute but robocopy copy showing

  Started : 11 April 2015 01:21:07 PM
   Source - F:\Training\HPES\CoreJava\
     Dest - F:\11-04-2015\

    Files :
  Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

ERROR : Invalid Parameter #3 : "\0121PM"

       Simple Usage :: ROBOCOPY source destination /MIR

             source :: Source Directory (drive:\path or \\server\share\path).
        destination :: Destination Dir  (drive:\path or \\server\share\path).
               /MIR :: Mirror a complete directory tree.

    For more usage information run ROBOCOPY /?


我的代码


My code

for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a

for /f "tokens=1,2,3 delims=: " %%A in ('TIME /T') do set mytime=%%A%%B%%C
pause
mkdir %datestr%
cd %datestr%
mkdir %mytime%
cd %mytime%

pause
robocopy F:\Training\HPES\CoreJava F:\%datestr%\%mytime%  /e
pause

它显示无效的参数错误,但是当我通过在源代码部分中删除%mytime%块来运行此代码时,一切正常.帮助

It is showing invalid parameter error but when i run this code by removing %mytime% block in source part then it works all good. HELP

推荐答案

for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a

date /t在其输出的末尾包含一个空格,该空格包含在datestr变量以及使用该变量执行的最终命令中.因此,F:\%datestr%\%mytime%包含一个空格(在%datestr%的末尾,将一个参数转换为两个参数.

the date /t includes an space at the end of its output, and this space is included in the datestr variable and in the final command you execute using the variable. So F:\%datestr%\%mytime% includes an space (at the end of %datestr%, converting one argument into two.

如果要保留空格,请使用引号:"F:\%datestr%\%mytime%"

If you want to keep the space, then use quotes: "F:\%datestr%\%mytime%"

如果您不想保留空间,请查看您的输出,可以更改为

If you don't want to keep the space, seeing your output you can change to

for /f %%a in ("%date%") do set "datestr=%%a"

这篇关于Robocopy显示无效参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆