中国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-02 11:37
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Help, about deleting files with batch commands!!
Printable Version  2,212 / 15
Floor1 xtay1625 Posted 2006-11-16 00:32
初级用户 Posts 9 Credits 128
I want to use a batch processing command to delete files. The file name is: xyz.com. How can I delete all xyz.com under the specified drive letter??? Thanks everyone, thank you.
Floor2 ccwan Posted 2006-11-16 00:56
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Copy one for you, no need to specify, delete all.
@echo off
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find "Fixed">nul && del /a /f /s !drive!\xyz.com
)
pause

If you want to specify under the C drive, use del /a /f /s c:\xyz.com
Floor3 lxmxn Posted 2006-11-16 00:58
版主 Posts 4,938 Credits 11,386
```
@echo off
set/p a=Please specify the drive letter of the file to be deleted: (Format like: C:)
set/p b=Please specify the file name to be deleted:
for /f "delims=" %%i in ('dir /s/b/a-d %a%\%b%') do del %%i
```
Floor4 xtay1625 Posted 2006-11-16 02:40
初级用户 Posts 9 Credits 128
It seems that none can be deleted normally, but still thank you all
Floor5 lxmxn Posted 2006-11-16 02:44
版主 Posts 4,938 Credits 11,386
Originally posted by xtay1625 at 2006-11-16 02:40:
It seems that none can be deleted normally, but thank you all the same


  Why can't it be deleted? Let's talk about your situation. The code can be appropriately modified to force deletion!

  It may not be deleted because it has a system attribute or the file is being used...
Floor6 ccwan Posted 2006-11-16 02:44
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Why can't it be deleted normally? Please describe the situation.
Floor7 redtek Posted 2006-11-16 02:55
金牌会员 Posts 1,147 Credits 2,902
The reason for the inability to delete normally is that the file to be deleted is in a directory with spaces ~:)
It must be that the "quotes" were forgotten to be written, haha ~:)
DEL "%%i"
……

Could it be that it's going to delete that "Viking" virus again? (That thing still infects executable files ~:)
Directly download the tool to specifically kill this virus from the virus official website ~:)

[ Last edited by redtek on 2006-11-16 at 02:58 AM ]
Floor8 ccwan Posted 2006-11-16 03:15
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Brother redtek is right. I always ignored the "" at first, and only improved after everyone's reminder. A single sentence... Details determine success or failure!
Floor9 NaturalJ0 Posted 2006-11-16 03:33
银牌会员 Posts 533 Credits 1,181
Is it okay to use del /s /f xyz.com?
Floor10 lxmxn Posted 2006-11-16 03:37
版主 Posts 4,938 Credits 11,386
Hehe, I really didn't notice this small detail.
Floor11 ccwan Posted 2006-11-16 03:45
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Originally posted by NaturalJ0 at 2006-11-16 03:33:
del /s /f xyz.com
Is this okay?



It seems to only support the current path.

Tried it. When the batch file is in the root directory, it works completely. But if it's in a subdirectory, it can't delete files in the parent directory.

[ Last edited by ccwan on 2006-11-16 at 03:52 AM ]
Floor12 lxmxn Posted 2006-11-16 03:55
版主 Posts 4,938 Credits 11,386
Originally posted by ccwan at 2006-11-16 03:45:

It seems to only support the current path.

Tried it, when the batch file is in the root directory, it works completely, but if it is in a subdirectory, it cannot delete files in the parent directory.

[ Last edited by ccwan on 2006-1 ...


  Just add a drive letter: del /s/f c:\abc.cba
Floor13 NeverLand Posted 2006-11-21 01:00
初级用户 Posts 11 Credits 28
Originally posted by lxmxn at 2006-11-15 03:55 PM:


  Add a drive letter: del /s/f c:\abc.cba



Tried it, works
Floor14 wu9910 Posted 2006-11-21 02:41
初级用户 Posts 13 Credits 28
for %%i in (xyz.com) do del c:\%%i /a/s/f
for %%i in (xyz.com) do del d:\%%i /a/s/f
for %%i in (xyz.com) do del e:\%%i /a/s/f
for %%i in (xyz.com) do del f:\%%i /a/s/f
for %%i in (xyz.com) do del g:\%%i /a/s/f
There's nothing left.
But in the hidden file folder, I can't do anything.
I'm a newbie, don't laugh at me. Can you simplify it? There's no /s command for del in DOS, please give me some advice, expert.

[ Last edited by wu9910 on 2006-11-21 at 01:35 AM ]
Floor15 tao0610 Posted 2006-11-21 03:07
高级用户 Posts 218 Credits 579
Originally posted by wu9910 at 2006-11-21 02:41 AM:
for %%i in (xyz.com) do del c:\%%i /a/s/f
for %%i in (xyz.com) do del d:\%%i /a/s/f
for %%i in (xyz.com) do del e:\%%i /a/s/f
for %%i in (xyz.com) do del f:\%%i /a/s/f
for %%i in (xyz.com) do d ...



Making a simple problem complicated...
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023