中国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-26 01:19
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » How to write such a batch processing.. Thanks
Printable Version  1,966 / 10
Floor1 gslingyun Posted 2006-06-28 13:14
初级用户 Posts 9 Credits 26
I want to keep only one NET folder on drive E. Delete all folders and files except this folder. And don't change the attributes of the NET folder. How to write such a batch script? Thanks for the advice.
Floor2 3742668 Posted 2006-06-28 14:00
荣誉版主 Posts 718 Credits 2,013
Briefly introduce two methods:

1. Traditional for method:


2. WMIC
Using WMIC, not only the probability of errors is much smaller, but also the execution speed is good.
wmic fsdir where "drive='e:' and filename!='NET'" call delete /NOINTERACTIVE
This sentence can delete other directories on drive E except net. However, because during testing, there was a situation where files in multi-level directories could not be completely deleted at once, so it is best to add a statement to judge whether there is only the net directory in the current directory:


CMD is profound. Of course, there are more than these two methods to achieve the purpose of the landlord. It can also use special files, directory names, directory special attributes and other methods. Looking forward to the next floor to explore.
Floor3 gslingyun Posted 2006-06-28 16:21
初级用户 Posts 9 Credits 26
Floor4 gslingyun Posted 2006-06-28 16:25
初级用户 Posts 9 Credits 26
Method 1 works very well.. Method 2 is not the kind I want. Because it will delete the files in the NET folder but not the folder. Thank you very much for your technical support.. Learned it..
Floor5 gslingyun Posted 2006-06-28 16:35
初级用户 Posts 9 Credits 26
Floor6 qq82015930 Posted 2006-08-31 03:11
中级用户 Posts 109 Credits 235
Please clarify the specific content that needs to be translated. You only provided "知道的告诉我一下 。QICQ:82015930", and it seems incomplete. Please provide the full text that needs to be translated.
Floor7 yanzhong Posted 2006-09-01 21:10
新手上路 Posts 7 Credits 18
Thanks, I've also learned a trick
Floor8 kennyfan Posted 2006-09-19 04:39
中级用户 Posts 112 Credits 259
Heheh, not bad. I'm here to give a thumbs up!~
Floor9 kcdsw Posted 2006-09-19 08:11
中级用户 Posts 179 Credits 404
Floor10 uime Posted 2006-09-20 05:33
初级用户 Posts 27 Credits 70 From 河南
DEL attributes]] names
ERASE attributes]] names

names Specify one or more file or directory lists. Wildcards can be used to delete multiple files. If a directory is specified, all files in the directory will be deleted.

/P Prompt for confirmation before deleting each file.
/F Force deletion of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode. Do not require confirmation when deleting global wildcards.
/A Select files to delete based on attributes.
attributes R Read-only files S System files
H Hidden files A Archive files
- Prefix indicating "no"

Can be accomplished with attrib, but it will change the attributes of the folder

[ Last edited by uime on 2006-9-20 at 05:35 ]
Floor11 pengfei Posted 2006-09-20 10:09
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
Heheh~ Learned two new commands
pushd
popd
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023