我只是想移动的所有文件和子目录d:\temp\test
来d:\temp\archive
,所以我尝试了这些命令:
move d:\temp\test\* d:\temp\archive\
move d:\temp\test\*.* d:\temp\archive\
但是我得到这个错误作为回报:
The filename, directory name, or volume label syntax is incorrect.
然后,我在网上进行了挖掘,并在doc bat中尝试了此操作:
for %%F in ( d:\temp\test\*.* ) do move /Y %%F d:\temp\archive
这次它没有显示任何错误,但是一切都停滞不前,没有进行任何更改。
我在这里想念什么?我正在Windows 10上尝试此操作。
好的,如果您只想从\test
\内部移动所有文件目录,则将首先处理文件,然后成批处理目录。for / d将复制目录以及子目录和文件。
@echo off
move "d:\temp\test\*" "d:\temp\archive"
for /d %%a in ("D:\temp\test\*") do move "%%~fa" "d:\temp\archive\"
作为附带说明,在下面运行时从cmd发送错误。
move d:\temp\test\* d:\temp\archive
那是因为它将移动所有文件,但不移动目录。如果The filename, directory name, or volume label syntax is incorrect.
没有,则没有文件,只有move命令看不到的文件夹。
注意从批处理文件中,将/Y
禁用该开关,并且如果存在文件夹,则不会替换文件夹。因此,如果您打算经常进行覆盖,或者改而使用xcopy
和更新存档,则在d:\temp
成功复制文件后立即运行删除操作。
最后,始终将路径包含在double中"
。在这种情况下,不用双引号就可以正常工作,但是如果您有类似的东西move d:\program files\temp\* d:\temp\archives
,由于程序和文件之间的空间会产生错误,因此始终最好使用move "d:\program files\temp\*" "d:\temp\archive
编辑了解%%~
分配。在这些示例中,我们使用%%I
代替%%a
%~I : expands %I removing any surrounding quotes (")
%~fI : expands %I to a fully qualified path name
%~dI : expands %I to a drive letter only
%~pI : expands %I to a path only
%~nI : expands %I to a file name only
%~xI : expands %I to a file extension only
%~sI : expanded path contains short names only
%~aI : expands %I to file attributes of file
%~tI : expands %I to date/time of file
%~zI : expands %I to size of file
%~$PATH:I : searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
if the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI : expands %I to a drive letter and path only
%~nxI : expands %I to a file name and extension only
%~fsI : expands %I to a full path name with short names only
%~dp$PATH:I : searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI : expands %I to a DIR like output line`
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句