China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 23:14
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Help! How to find the required folder and delete it (solved) View 2,962 Replies 17
Original Poster Posted 2006-07-03 09:23 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
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 ]
Floor 2 Posted 2006-07-03 10:06 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
for /d /r %a in (c:\windows\$*$) do @rd /s /q "%a"
Not tested yet............
Floor 3 Posted 2006-07-03 10:12 ·  中国 江苏 盐城 电信
新手上路
Credits 6
Posts 3
Joined 2006-07-03 10:11
20-year member
UID 57917
Status Offline
for /f %i in ('dir %systemroot% /adh /b ^|find "$NtUninstall"') do @echo %systemroot%\%i
Floor 4 Posted 2006-07-03 15:57 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
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.
Floor 5 Posted 2006-07-03 17:11 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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.
Floor 6 Posted 2006-07-03 18:52 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
I followed what you wrote, and there is a space before do.
Floor 7 Posted 2006-07-03 21:49 ·  中国 辽宁 葫芦岛 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
21-year member
UID 40733
Gender Male
Status Offline
Try changing the sentence.

for /D %a in ("%windir%\$*$") do @rd /s /q "%a"
Wunaihe 2006-07-03 21:42
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Floor 8 Posted 2006-07-04 06:37 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
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
Floor 9 Posted 2006-07-04 08:50 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
Austion, I'm sorry, I can't solve your problem...
Floor 10 Posted 2006-07-04 09:26 ·  中国 广东 广州 天河区 电信
荣誉版主
★★★
Credits 718
Posts 313
Joined 2005-09-26 00:00
20-year member
UID 42844
Gender Male
Status Offline
There should be no windira at this time


It's windir!!!
Floor 11 Posted 2006-07-04 09:56 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
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"
Floor 12 Posted 2006-07-04 10:18 ·  中国 江苏 盐城 电信
新手上路
Credits 6
Posts 3
Joined 2006-07-03 10:11
20-year member
UID 57917
Status Offline
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
Floor 13 Posted 2006-07-04 15:57 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
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 ]
Floor 14 Posted 2006-07-07 08:55 ·  中国 广东 佛山 电信
初级用户
★★
Credits 178
Posts 82
Joined 2006-05-12 23:53
20-year member
UID 55419
Status Offline
Push it up, hope there are experts to help
Floor 15 Posted 2006-07-09 10:14 ·  中国 河南 郑州 电信
中级用户
Credits 207
Posts 41
Joined 2004-10-24 00:00
21-year member
UID 32885
Gender Male
Status Offline
@echo off
dir /s /b /ah c:\$*$>clean.txt
for /f %%i in (clean.txt) do @rd /s /q "%%i"
Forum Jump: