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-07 14:42
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Unresolved] Batch non-empty judgment access and deletion of slightly deformed directories View 15,534 Replies 67
Floor 31 Posted 2008-03-09 10:44 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Then I'll make a bomb and challenge plp626... If I can get it done at once... You must teach me the method!
Surfing the Internet in an Internet cafe, can't make anything complicated... Failed... But I took out the previous autorun multiple immunity... Let's try
::Should... It won't cause bad results. Suitable for NTFS formatted disks
@echo off
set /p n=Enter the number of non-deletable files to create here, no judgment. Best is 1^<n^<50___:
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a: (
%%a: &cd\
for /f "tokens=*" %%b in ('dir /a-d /b autorun.inf') do (del /a /f /q %%b)
::If there is still autorun.inf at this time, it should be a folder that cannot be deleted
if exist autorun.inf goto :fail
md autorun.inf &cd autorun.inf
for /l %%d in (1,1,%n%) do (md %%d%%d &md %%d%%d\con\)
cd..
attrib autorun.inf +a +s +h +r
echo y |cacls autorun.inf /p everyone:n
))

:2
cls
echo Do you want to cancel?
set /p in=(y/n)
if /i %in%==y goto delete
if /i %in%==n (exit) else (goto 2)

:delete
set /p m=Enter the number here, no judgment. Best is 1^<n^<50___:
for %%c in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%c:\autorun.inf (
%%c: &cd\
echo y |cacls autorun.inf /p everyone:f
cd autorun.inf
for /l %%e in (1,1,%m%) do (rd %%e%%e\con\)
cd..
rd autorun.inf /s /q
))
exit

:fail
echo It may have been established, or other problems occurred, press any key to go to the delete item.
pause>nul
goto :2

[ Last edited by 523066680 on 2008-3-9 at 11:09 AM ]
Floor 32 Posted 2008-03-09 11:42 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
There is a difference between setting permissions with cacls and with dots. You provided delete here?
Floor 33 Posted 2008-03-09 12:50 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
plp626 The code on the tenth floor I can delete! But the deeper ones... need to be modified.

At the beginning, I didn't add "|find /v "bytes"", resulting in cd.. to the upper folder, causing my other files to be deleted... So sad & now it's okay.

Because it's tokens=4, so if it's not a long-named folder, it won't be mistakenly deleted.

It should be said that it's a defect in judgment. I have limited knowledge. The following code was made in an internet cafe.
Hope someone is willing to optimize it... Be careful, it's easy to mistakenly delete the outer folder...

[ Last edited by 523066680 on 2008-3-9 at 01:11 PM ]
Floor 34 Posted 2008-03-09 12:56 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
=============Wrong solution! ==Browsers please skip======



@echo off
echo. Now start creating a malformed folder, here is the code of plp626
pause
@echo off
for %%a in (plp 626 cn dos 1 0 fdf d ret 就是 lo aux com1 nul con pp 465 漂来漂 看 ai) do (
md %%a...\ %%a...\...\
for %%a in (con nul aux com1) do (
md %%a...\%%b\
copy *.bat "%%a...\%%b\"
md %%a...\%%b\con\
) )

cls
echo. Established
pause

::\\\\\\\\\\\\\\\\\\\\\\\\Start to remove, 、、、、、、、、、、
::Here is my code, if you deal with deeper code, you have to change it again!


@echo off
for /f "skip=7 tokens=4" %%a in ('dir /ad /x ^|find /v "bytes"') do (
echo %%a
cd %%a
for /f "tokens=*" %%b in ('dir /ad /b') do (
echo %%~nb
for /f "tokens=*" %%c in ('dir %%~nb\ /ad /b') do (
echo %%~nb\%%~nc\
rd %%~nb\%%~nc\ /s /q
)
rd %%~nb\ /s /q
)
cd..
echo %%a
rd %%a /s /q
)
pause


[ Last edited by 523066680 on 2008-8-21 at 07:22 AM ]
Floor 35 Posted 2008-03-09 13:17 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
To be honest, I'm not very convinced that anyone can write general-purpose code.

con\This layer is a normal folder\nul\a..\nul\con\aux\haha.x... Challenging the limit... If plp626 can do it generically, I will worship you!! Idol! Look at the code on my 31st floor! Give your evaluation.

Other experts also do it... The so-called selfless dedication! At most, it's restricted - only those with XX points in this post can enter. Of course, it can't be higher than my points...

[ Last edited by 523066680 on 2008-3-9 at 01:22 PM ]
Floor 36 Posted 2008-03-09 13:32 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Are you discussing whether to delete all folders or only those without files later? The one you posted on floor 34 seems to have deleted all folders?
Floor 37 Posted 2008-03-09 14:15 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Alas... I didn't read the question clearly...

[ Last edited by 523066680 on 2009-3-18 at 03:34 ]
Floor 38 Posted 2008-03-09 14:15 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Why do you care about the number of layers? Isn't it that only dir can be used to view directories? You can directly use rd to see the error message, and then rd... Oops...
Floor 39 Posted 2008-03-09 14:22 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
That makes sense... I thought about -- the part about cracking autorun immunity...
This is a water post!
Floor 40 Posted 2008-03-09 15:17 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
It seems that what the 38th floor said... I can't do it...
Floor 41 Posted 2008-03-09 15:30 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Floor 25 has already said
Copy handle!
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 42 Posted 2008-03-09 15:47 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Viruses may be more perverse than you think,
But no matter how perverse they are, they can be eliminated. I have an idea (for discussion):
Using 2>&1 to get the deep path of the malformed directory, and then using for to analyze the path to eliminate all malformed directories should not be a problem,

I don't know where 2>&1 comes from... Please enlighten me! Thank you
Floor 43 Posted 2008-03-09 15:51 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
It's being tested, but there are many bugs.
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 44 Posted 2008-03-09 16:17 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
I'm optimizing the code, please wait a moment....
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 45 Posted 2008-03-09 16:22 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Delete the... on the 10th floor of plp26.

I just wrote a test script, you can expand it yourself.

Create a TEST directory, and create the generation script for plp626 in it. Run it.

Write the following script outside the TEST directory.

@echo off
rd /s /q %1\ 2>srd.log
for /f %%i in (srd.log) do rd /s /q %%i\
rd /s /q %1\ 2>srd.log

Drag the TEST folder up to delete it.
Forum Jump: