[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] 怎么批量删除*font*文件夹

RD貌似不支持通配符
而且*font*文件夹  所在的文件夹,文件夹极多,枚举可能不现实

举一个失败的例子方便理解吧
RD /s /q "c:\Windows\WinSxS\*font*"

本帖最后由 不知道是谁 于 2020-4-29 17:31 编辑
  1. for /f "delims=" %%i in ('dir /ad /b /s %WinDir%\WinSxS\*font*') do echo %%i
复制代码
测试通过后替换 do 后面的

TOP

回复 2# 不知道是谁


正好有类似匹配文件夹问题,用到了,感谢。

for /f "delims=*" %%i in ('dir /ad /b /s %PATH%\* ') do (
move "%%i" "%PATH%"

上面这个语句直接把最深一级的子目录移动到当前目录了。
如果我只想把当前目录下的第一级子目录移动到当前目录,请问有办法吗?  谢谢

TOP

回复 3# pcxnice


    %PATH%是系统默认环境变量,不建议自定义变量也使用%PATH%
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 4# Batcher


感谢指点。

用PATH是为了适用性,用的时候比较多。都是复制到该目录下直接就用 了,所以没有修改为绝对路径。

TOP

回复 2# 不知道是谁


    如果要反过来,除了*font*文件夹以外的文件夹全部删除,怎么写呢

TOP

回复  不知道是谁


正好有类似匹配文件夹问题,用到了,感谢。

for /f "delims=*" %%i in ('dir /a ...
pcxnice 发表于 2020-4-30 11:38



    去掉 /s 试试

TOP

回复  不知道是谁


    如果要反过来,除了*font*文件夹以外的文件夹全部删除,怎么写呢
hentai87 发表于 2020-4-30 15:40
  1. @echo off
  2. set str=%WinDir%\WinSxS
  3. for /f "delims=" %%i in ('dir /ad /b /s %str%^|find /v "*font*"') do echo %%i
  4. pause
复制代码

TOP

本帖最后由 hentai87 于 2020-4-30 19:20 编辑

回复 8# 不知道是谁


D:\ZT\msmg9.8\Mount\Install\Windows\SystemApps>set str=D:\ZT\msmg9.8\Mount\Install\Program Files\WindowsApps

D:\ZT\msmg9.8\Mount\Install\Windows\SystemApps>for /F "delims=" %i in ('dir /ad /b /s "D:\ZT\msmg9.8\Mount\Install\Program Files\WindowsApps"|find /v "Microsoft.UI.Xaml*"') do RD /S /Q "%i"

D:\ZT\msmg9.8\Mount\Install\Windows\SystemApps>RD /S /Q "D:\ZT\msmg9.8\Mount\Install\Program Files\WindowsApps\Microsoft.UI.Xaml123123123"

D:\ZT\msmg9.8\Mount\Install\Windows\SystemApps>RD /S /Q "D:\ZT\msmg9.8\Mount\Install\Program Files\WindowsApps\New folder"

D:\ZT\msmg9.8\Mount\Install\Windows\SystemApps>pause
失败了,删了不该删的Microsoft.UI.Xaml123123123

TOP

回复 9# hentai87
  1. @echo off
  2. set str="D:\ZT\msmg9.8\Mount\Install\Program Files\WindowsApps"
  3. for /f "delims=" %%i in ('dir /ad /b /s %str%^|findstr /v "Microsoft.UI.Xaml*"') do echo %%i
  4. pause
复制代码

TOP

返回列表