cmd 文件的通配符
我目前正在使用这个语句:
for /d %%X in (C:\Users\*) do (del %%X\Desktop\deleteme.txt )
虽然我想在这个语句的某些部分使用“%%X”,
例如
del %%X\%%X\deleteme.txt
这怎么能做到呢?
任何帮助将不胜感激
I am currently using this statement:
for /d %%X in (C:\Users\*) do (del %%X\Desktop\deleteme.txt )
Although I would like to use the "%%X" in to parts of this statement
e.g.
del %%X\%%X\deleteme.txt
How can this be done?
Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来你想递归删除文件。这可以通过直接使用 del 命令来完成。通过输入:
del deleteme.txt /s
deleteme.txt 将从所有子文件夹中删除。如果这不是您想要的,您也可以让 for 循环调用另一个批处理文件来执行从子文件夹中的删除。
%%X 将不起作用,因为它首先完全展开。
It seems like you want to recursively delete files. This could be done by using the del command directly. By typing:
del deleteme.txt /s
deleteme.txt will be deleted from all subfolders. If that is not what you want you also could have your for loop call another batch file to perform the deletion from sub folders.
%%X will not work, as it gets fully expanded first.