cmd 文件中的通配符
我面临着一种情况,我需要删除所有用户目录中的一个文件,
例如,
C:\Users\User1\Desktop\deleteme.txt
C:\Users\User2\Desktop\deleteme.txt
C:\Users\User3\Desktop\deleteme.txt
我需要一个将用户目录视为通配符的命令,所以我不需要指定任何内容。
我已经尝试过:
C:\Users\*\Desktop\deleteme.txt
哪个不起作用:(
任何帮助将不胜感激
I am faced with a situation where I need to delete one file in all users directories
E.g.
C:\Users\User1\Desktop\deleteme.txt
C:\Users\User2\Desktop\deleteme.txt
C:\Users\User3\Desktop\deleteme.txt
I am in need of a command that will treat the users directory as a wildcard, so I don't need to specify anything.
I have tried:
C:\Users\*\Desktop\deleteme.txt
Which doesn't work :(
Any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试迭代所需的文件夹:
或者
有一篇很好的文章
使用“For”迭代
更新
这样:
您可以列出所有用户文件夹中的所有子目录。
You may try iterating the needed folders :
or
There is a good article
Iterating with "For"
UPDATE
In this way :
You can list all subdirectories in all user's folders.
我以为
C:\Users
之后可能缺少反斜杠,但事实并非如此。正如我刚刚注意到的,这是语法问题。星号前面的反斜杠被省略。如果批处理文件不够用并且您仅在 Windows 7 上工作,您可以切换到 PowerShell
I thought there might be a backslash missing after
C:\Users
, but it isn't. It's a problem of the syntax here, as I just noticed. A backslash in front of an astrisk is omitted.If a batch file proves unsufficient and you are working on Windows 7 only, you could switch to PowerShell