中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-01 22:12
48,037 topics / 350,122 posts / today 2 new / 48,250 members
DOS批处理 & 脚本技术(批处理室) » Help! How to find the required folder and delete it (solved)
Printable Version  2,959 / 17
Floor1 austion Posted 2006-07-03 09:23
初级用户 Posts 82 Credits 178
Since Windows upgrades generate $****$ folders in the %windir% directory, and generally these folders are useless, so I want to make a batch script to delete these folders.
That is, how to delete all the upgrade backup folders $****$ in the %windir% directory and all their contents? Deleting files can use wildcards, but del doesn't work. Using rd also requires the full name. How to use wildcards?

[ Last edited by austion on 2006-7-13 at 19:22 ]
Floor2 bagpipe Posted 2006-07-03 10:06
银牌会员 Posts 425 Credits 1,144 From 北京
for /d /r %a in (c:\windows\$*$) do @rd /s /q "%a"
Not tested yet............
Floor3 doudou Posted 2006-07-03 10:12
新手上路 Posts 3 Credits 6
for /f %i in ('dir %systemroot% /adh /b ^|find "$NtUninstall"') do @echo %systemroot%\%i
Floor4 austion Posted 2006-07-03 15:57
初级用户 Posts 82 Credits 178
After testing, the content from the 2nd floor:
There should not be "do" at this time
The content from the 3rd floor:
The command syntax is incorrect

The above are the test results.
Floor5 bagpipe Posted 2006-07-03 17:11
银牌会员 Posts 425 Credits 1,144 From 北京
I think you'd better take a look. I think there's no problem. There's a space after the ) symbol and then comes DO. The grammar problem on the third floor is that he made a mistake in the single quotes. It should be changed to '"........."' or '.......^| .........' and so on.
Floor6 austion Posted 2006-07-03 18:52
初级用户 Posts 82 Credits 178
I followed what you wrote, and there is a space before do.
Floor7 无奈何 Posted 2006-07-03 21:49
荣誉版主 Posts 356 Credits 1,338
Try changing the sentence.

for /D %a in ("%windir%\$*$") do @rd /s /q "%a"
Wunaihe 2006-07-03 21:42
Floor8 austion Posted 2006-07-04 06:37
初级用户 Posts 82 Credits 178
bagpipe:
The grammar problem on the third floor is that he made a mistake in the single quotes. It should be changed to the form of '"........."' or '.......^| .........' to be correct.
Then how to change it? I'm not familiar with for and don't understand it very much.
Helpless:
I don't know why, when I use the statement you gave on my computer, it says: "At this time, there should not be windira"
It hasn't been verified on other computers
Floor9 bagpipe Posted 2006-07-04 08:50
银牌会员 Posts 425 Credits 1,144 From 北京
Austion, I'm sorry, I can't solve your problem...
Floor10 220110 Posted 2006-07-04 09:26
荣誉版主 Posts 313 Credits 718
There should be no windira at this time


It's windir!!!
Floor11 austion Posted 2006-07-04 09:56
初级用户 Posts 82 Credits 178
I entered it as I had to, but the result indeed shows: "At this time there should not be windira"

It's not windir or windira but it says windira "

My input is for /D %a in ("%windir%\$*$") do @rd /s /q "%a"
I wrote %windir% but the result shows: "At this time there should not be windira"
Floor12 doudou Posted 2006-07-04 10:18
新手上路 Posts 3 Credits 6
Heheh, is it true or false, I really tested it before posting it.
The building owner needs to replace %i with %%i in the batch processing.
I directly input it in the command line.
Hey
Floor13 austion Posted 2006-07-04 15:57
初级用户 Posts 82 Credits 178
doudou:
I also did as you said and replaced %i with %%i.
There was no problem popping up, but still couldn't delete the required folder. Look at the picture.



[ Last edited by austion on 2006-7-7 at 08:54 ]
Floor14 austion Posted 2006-07-07 08:55
初级用户 Posts 82 Credits 178
Push it up, hope there are experts to help
Floor15 flysp Posted 2006-07-09 10:14
中级用户 Posts 41 Credits 207
@echo off
dir /s /b /ah c:\$*$>clean.txt
for /f %%i in (clean.txt) do @rd /s /q "%%i"
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023