中国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-25 23:45
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » Please provide more specific information, such as what programming language or scripting environment you are using (e.g., batch script for Windows, Python, etc.), so that I can write a more targeted script.
Printable Version  8,366 / 15
Floor1 woof Posted 2006-11-22 22:43
新手上路 Posts 5 Credits 12
As the title says, I use del /q /s /arh filename. But if it's a folder or a hidden and read-only file that can't be deleted, how should I do it? Thanks.
Floor2 afeichai Posted 2006-11-22 22:49
初级用户 Posts 78 Credits 171
Try using RD /q/s. If you still need to keep the folder, you can recreate it with MD.
Floor3 woof Posted 2006-11-22 23:12
新手上路 Posts 5 Credits 12
This is just deleting the directory. Now I'm dealing with ordinary files. If they are both hidden and read-only, they can't be deleted. Only by removing /s/q can it be deleted, but in that case, ordinary files can't be deleted either.
Floor4 redtek Posted 2006-11-22 23:50
金牌会员 Posts 1,147 Credits 2,902
RMDIR /S /Q the directory name you want to delete

(Files with read-only and hidden attributes in the directory can still be deleted along with the directory, which has been verified)
(However, the directory to be deleted must not have files that are running or "occupied" by the system, then it can be deleted)

You must delete outside the directory name you want to delete to be able to delete it:)
If you are deleting a directory named: ABC, but you are in this ABC directory at this time, then this directory is being used (occupied) by you, so it cannot be deleted.

After deleting the directory, you can re-create a directory with the same name, which is equivalent to deleting all the files in this directory.
This operation is just to be "省事" (save effort):)

) The above method is a time-saving method, that is, delete all files and subdirectories under the target directory, and then re-create.

) At the same time, I have simulated and built a directory on my machine according to the above principle operation. This directory is hidden + read-only.
  At the same time, several subdirectories are built in this directory, all hidden + read-only,
  At the same time, n files are built in these subdirectories, and the file attributes are all hidden + read-only

  Then, I execute RMDIR /S /Q the directory name I want to delete in a directory above the directory to be deleted.
  The test was successful! (Test environment: Windows Server 2003 CMD Shell)

[ Last edited by redtek on 2006-11-22 at 10:55 AM ]
Floor5 ccwan Posted 2006-11-23 00:08
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Brother redtek explained the problem patiently and carefully, and did tests himself, with a sincere attitude. Appreciate it, add points.
Floor6 不得不爱 Posted 2006-11-23 00:18
超级版主 Posts 2,044 Credits 5,310 From 四川南充
del /q /s /f /a filename
You can delete all contents in the folder, including hidden and read-only files. If it is a folder, it will not be deleted
Floor7 woof Posted 2006-11-23 02:25
新手上路 Posts 5 Credits 12
Originally posted by Must Love at 2006-11-22 11:18 AM:
del /q /s /f filename
You can delete all contents in the folder, including hidden and read-only files. If it is a folder, it will not be deleted



For example
If you want to delete all files in the temp folder

del /q /s /f temp

The result is that if there is a hidden and read-only file in this folder, it cannot be deleted

My system is Traditional Chinese Windows XP SP1,
Floor8 afeichai Posted 2006-11-23 02:29
初级用户 Posts 78 Credits 171
This is what I did
@RD /q/s %Temp%
@MD %Temp%
It can be realized in XPSP2 and 2003SP1
Floor9 不得不爱 Posted 2006-11-23 02:37
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Add /A to the 7th floor
Floor10 redtek Posted 2006-11-23 02:47
金牌会员 Posts 1,147 Credits 2,902
There is a directory for temporary file storage specified by the Windows system: 2006-11-22 13:44 <DIR> Temporary Internet Files

If you execute the command: rmdir /s /q "Temporary Internet Files", some files cannot be deleted.
Because these files are files that are currently being opened and used.
If system files that are currently being opened and used could also be deleted, that would be too insecure, haha...




But when I close the IE browser, and then I execute the command: rmdir /s /q "Temporary Internet Files"
I will find that now only one file cannot be deleted :)



Files that are currently being opened and used by the system cannot be generally deleted, which is for the sake of system security :)

[ Last edited by redtek on 2006-11-22 at 01:52 PM ]
Floor11 woof Posted 2006-11-23 02:51
新手上路 Posts 5 Credits 12
Just add -a, OK, thanks. But what about the folder? Just add another command? Is there a command to delete all files (including folders) but not delete the directory itself? Thanks everyone
Floor12 electronixtar Posted 2006-11-23 07:05
铂金会员 Posts 2,672 Credits 7,493
Those who can delete index.dat must have really high skills.
Floor13 tao0610 Posted 2006-11-23 07:16
高级用户 Posts 218 Credits 579
index.dat can be cleared under DOS, or you can log in with another account to clear it! The software Tracks Eraser Pro can also be used. But it's not necessary to go to so much trouble for a little history (unless you're being targeted by hackers or doing something illegal)
Floor14 anqing Posted 2006-11-23 07:28
高级用户 Posts 413 Credits 859
The contents in the temp folder, some are occupied by the system and cannot be deleted. I don't know what method can be used to delete them. Can you write a bat?
Floor15 anqing Posted 2006-11-23 07:32
高级用户 Posts 413 Credits 859
Originally posted by afeichai at 2006-11-23 02:29:
This is what I did
@RD /q/s %Temp%
@MD %Temp%
It can be implemented in XPSP2 and 2003SP1

If there are programs occupying the temp folder, can the temp folder still be deleted?
Can someone write a VBS script for us to learn? How to use the VBS script?
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023