我有两个命令。第一个工作正常,但第二个没有。我一直收到错误,"找不到......"即使文件确实存在于那里。为什么要赢得del工作,但回声会如何?我尝试删除该路径中扩展名为.jpg的所有文件。
forfiles /p "C:\Users\hi\Desktop\test" /m *.jpg /d -1 /c "cmd /c echo @path @fdate"
pause
forfiles /p "C:\Users\hi\Desktop\test" /m *.jpg /d -1 /c "cmd /c del @path @srchmask"
pause
答案 0 :(得分:3)
del
工作但echo
会工作? echo
只输出您告诉它的任何内容。
forfiles /p "C:\Users\hi\Desktop\test" /m *.jpg /d -1 /c "cmd /c del @path @srchmask"
以上命令不正确。没有"命令变量"为@srchmask
命令定义了forfiles
:
Command Variables:
@file The name of the file.
@fname The file name without extension.
@ext Only the extension of the file.
@path Full path of the file.
@relpath Relative path of the file.
@isdir Returns "TRUE" if a file type is a directory,
and "FALSE" for files.
@fsize Size of the file in bytes.
@fdate Last modified date of the file.
@ftime Last modified time of the file.
来源forfiles。
您已将/m *.jpg
指定为" searchmask"对于forfiles
命令,我不确定您打算使用@srchmask
做什么。您可以尝试删除它......
如果您需要其他选项而不是@srchmask
,您还应该阅读del的语法...