批处理文件Del - 无法找到

时间:2016-07-26 20:15:05

标签: batch-file del

我有两个命令。第一个工作正常,但第二个没有。我一直收到错误,"找不到......"即使文件确实存在于那里。为什么要赢得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

1 个答案:

答案 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的语法...

进一步阅读