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-09-30 19:34
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Search for all executable files under the specified disk colon character View 6,821 Replies 41
Floor 31 Posted 2006-11-02 12:13 ·  中国 湖南 郴州 资兴市 电信
新手上路
★
Credits 18
Posts 9
Joined 2006-11-01 08:16
19-year member
UID 69129
Gender Male
From 湖南
Status Offline
Can someone explain that batch script? Thanks.
Floor 32 Posted 2006-11-03 02:00 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  The code above is as follows:

  Because this batch script deletes all executable files under the specified drive letter, the batch script first asks if you want to continue. If you choose y, the batch script jumps to the ":yes" label to execute the statements below the ":yes" label. If you choose n, the batch script directly jumps to the end of the file and exits directly.

  Then the batch script asks you to enter the drive letter to search. For example, entering a "D" assigns "D" to variable a to execute the following statements.

  This batch script uses the for + dir command. for is used to perform loop operations, that is, to execute the del command in a loop. The dir plus the "/b/s/a-d" parameter can enumerate all executable files under the specified drive letter. Each file enumerated is assigned to variable %%i, and then del %%i deletes it.
Floor 33 Posted 2006-11-03 07:11 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
If I remember correctly, a lot was discussed before
Floor 34 Posted 2006-11-07 01:54 ·  中国 广东 肇庆 电信
初级用户
★
Credits 44
Posts 16
Joined 2006-09-23 22:11
20-year member
UID 63478
Gender Male
From 广东省
Status Offline
Then, if I change deletion to copying, how should I write it?
Floor 35 Posted 2006-11-07 05:49 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
21-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Just change DEL to COPY.
——————————————————Moderation Record——————————————————
Performed by: Must Love
Explanation: Multiple posting, {there are identical topics in DOS Batch & Script Technology (Batch Room), DOS Troubleshooting & Question Discussion (Help Room), DOS Learning Introduction & Exciting Articles (Teaching Room)}
Action: Merge 3 identical topics and delete the original poster's duplicate posts
————————————————————————————————————————


[ Last edited by Must Love on 2006-11-6 at 05:51 PM ]
Floor 36 Posted 2006-11-07 08:32 ·  中国 广东 肇庆 电信
初级用户
★
Credits 44
Posts 16
Joined 2006-09-23 22:11
20-year member
UID 63478
Gender Male
From 广东省
Status Offline
I have made changes. If I use the one given on the 5th floor and change DEL to COPY, for example, I want to copy to the 123 file under F:, then how should I write it? Please the moderator explain it to me carefully, okay?
Floor 37 Posted 2006-11-07 10:33 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline


@echo off
set /p a=Please enter the drive letter to search:
echo.
for /f %%i in ('dir /s/b/a-d %a%:\*.exe') do copy %%i F:\123
echo
Floor 38 Posted 2006-11-07 10:39 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
21-year member
UID 42843
Gender Male
From 四川南充
Status Offline
@echo off
set /p a=Please enter the drive letter to search:
for /f "tokens=*" %%i in ('dir /s/b/a-d C:\*.TXT') do copy “%%i” F:\123
echo The specified file has been copied to the F:\123 directory.
pause
Floor 39 Posted 2006-11-08 10:54 ·  中国 广东 肇庆 电信
初级用户
★
Credits 44
Posts 16
Joined 2006-09-23 22:11
20-year member
UID 63478
Gender Male
From 广东省
Status Offline
Thank you so much, everyone.. I can do it now
Floor 40 Posted 2006-11-08 12:05 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Haha, I'm quite experienced in killing this virus oh
del D:\**.logo1_.exe /s /a /f /q
del c:\**.logo1_.exe /s /a /f /q

Change a few more disks by yourself, also I uploaded a JS script before to kill it, definitely thorough oh! 1

Go find it!
Floor 41 Posted 2007-07-11 10:06 ·  中国 湖北 武汉 电信
初级用户
★
小子
Credits 76
Posts 26
Joined 2007-06-20 19:30
19-year member
UID 91913
Gender Male
Status Offline
It's quite useful, but unfortunately it doesn't support Chinese paths.
Everyone can give it a try.
If you just want to search for all executable files under a specified drive letter, you can use the following code:

@echo off
:putin
set/p var=Please enter the drive letter to search:
if "%var%"=="" set var=%~d0
if not exist "%var%" cls&echo The directory you entered does not exist, please enter again!&goto putin
dir /s /b "%var%\*.exe"
pause


[ Last edited by tclgb on 2007-7-11 at 10:41 AM ]
Attachments
locate.zip (87.19 KiB, Downloads: 3)
Floor 42 Posted 2007-07-29 11:39 ·  中国 陕西 西安 电信
初级用户
★
Credits 106
Posts 44
Joined 2007-06-01 22:25
19-year member
UID 90001
Gender Male
Status Offline
Thanks to the brother above for the reminder, it turns out that Chinese paths are not supported.
Forum Jump: