Windows批处理文件删除包含空格的文件夹/子文件夹
我正在使用以下命令删除 10 天前的文件夹:
FORFILES /S /D -10 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"
但是如果 @path 变量包含空格,则不会删除该文件夹。
我尝试了“@path”但没有任何结果。有关于此的任何帮助。 谢谢,
I am using the below to delete folders 10 days old:
FORFILES /S /D -10 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"
BUT if the @path variable contains spaces it won't delete that folder.
I tried "@path" but nothing. Any help regarding this.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在文件夹中创建或修改文件不会更新文件夹时间戳。在父文件夹中创建或删除子文件夹将更新父文件夹时间戳。
您的带有空格的文件夹可能未被删除,因为子文件夹在过去 10 天内以某种方式被操纵。失败可能与名称中的空格无关。尝试从文件夹的父级执行
DIR
命令并查看该文件夹的日期。Creating or modifying files within a folder does not update the folder timestamp. Creating or deleting a child folder within the parent folder will update the parent folder timestamp.
Your folder with spaces probably was not deleted because a child folder was manipulated in some way within the last 10 days. The failure probably has nothing to do with spaces in the name. Try a
DIR
command from the parent of the folder and look at the date for the folder.