如何使用forfiles删除没有扩展名的文件
How to use forfiles to delete files without extension
我正在使用 forfiles 从特定目录中删除超过 7 天的文件,使用在本论坛其他地方找到的以下脚本:
forfiles -p "H:\E-drev" -m *.* /D -7 /C "cmd /c del @path"
这很好用,除了我有一些没有扩展名的文件,例如。一个名为 TA07l 的文件。这个文件没有被删除。我尝试使用 @fname
而不是 @path
但这没有帮助。
如有任何建议,我们将不胜感激。
您必须使用 *
而不是 *.*
,否则它将搜索包含点 .
的每个文件
更新 *
和 *.
和 *.*
之间的几个示例:
copy nul _onefilewithoutext
copy nul _onefilewith.ext
mkdir _oneFolder
dir /b /a-d *.
_onefilewithoutext
Forfiles
命令
forfiles /M *. /C "cmd /C echo @relpath"
Error: File Type "*." not found.
forfiles /M * /C "cmd /C echo @relpath"
".\_onefilewith.ext"
".\_onefilewithoutext"
".\_oneFolder"
forfiles /M *.* /C "cmd /C echo @relpath"
".\_onefilewith.ext"
forfiles /M * /C "cmd /C if @isdir==FALSE echo @relpath"
".\_onefilewith.ext"
".\_onefilewithoutext"
forfiles /M * /C "cmd /C if @isdir==FALSE if @ext==\"\" echo @relpath"
".\_onefilewithoutext"
以下应该有效:
forfiles /P "H:\E-drev" /M * /D -7 /C "cmd /C if @isdir==FALSE if @ext==\"\" del @path"
我正在使用 forfiles 从特定目录中删除超过 7 天的文件,使用在本论坛其他地方找到的以下脚本:
forfiles -p "H:\E-drev" -m *.* /D -7 /C "cmd /c del @path"
这很好用,除了我有一些没有扩展名的文件,例如。一个名为 TA07l 的文件。这个文件没有被删除。我尝试使用 @fname
而不是 @path
但这没有帮助。
如有任何建议,我们将不胜感激。
您必须使用 *
而不是 *.*
,否则它将搜索包含点 .
更新 *
和 *.
和 *.*
之间的几个示例:
copy nul _onefilewithoutext
copy nul _onefilewith.ext
mkdir _oneFolder
dir /b /a-d *.
_onefilewithoutext
Forfiles
命令
forfiles /M *. /C "cmd /C echo @relpath"
Error: File Type "*." not found.
forfiles /M * /C "cmd /C echo @relpath"
".\_onefilewith.ext"
".\_onefilewithoutext"
".\_oneFolder"
forfiles /M *.* /C "cmd /C echo @relpath"
".\_onefilewith.ext"
forfiles /M * /C "cmd /C if @isdir==FALSE echo @relpath"
".\_onefilewith.ext"
".\_onefilewithoutext"
forfiles /M * /C "cmd /C if @isdir==FALSE if @ext==\"\" echo @relpath"
".\_onefilewithoutext"
以下应该有效:
forfiles /P "H:\E-drev" /M * /D -7 /C "cmd /C if @isdir==FALSE if @ext==\"\" del @path"