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-06-30 20:26
中国DOS联盟论坛 » 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. View 8,087 Replies 15
Original Poster Posted 2006-11-22 22:43 ·  中国 江苏 南京 联通
新手上路
神話
Credits 12
Posts 5
Joined 2006-11-22 21:37
19-year member
UID 71389
Gender Male
Status Offline
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.
Floor 2 Posted 2006-11-22 22:49 ·  中国 陕西 安康 电信
初级用户
★★
Credits 171
Posts 78
Joined 2006-11-22 11:26
19-year member
UID 71373
Gender Male
Status Offline
Try using RD /q/s. If you still need to keep the folder, you can recreate it with MD.
Floor 3 Posted 2006-11-22 23:12 ·  中国 江苏 南京 联通
新手上路
神話
Credits 12
Posts 5
Joined 2006-11-22 21:37
19-year member
UID 71389
Gender Male
Status Offline
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.
Floor 4 Posted 2006-11-22 23:50 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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 ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
ccwan +3 2006-11-23 00:06
woof +1 2006-11-23 02:43
hxuan999 +1 2006-11-24 06:54
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 5 Posted 2006-11-23 00:08 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Brother redtek explained the problem patiently and carefully, and did tests himself, with a sincere attitude. Appreciate it, add points.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2006-11-23 00:18 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
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
Floor 7 Posted 2006-11-23 02:25 ·  中国 江苏 南京 联通
新手上路
神話
Credits 12
Posts 5
Joined 2006-11-22 21:37
19-year member
UID 71389
Gender Male
Status Offline
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,
Floor 8 Posted 2006-11-23 02:29 ·  中国 陕西 安康 电信
初级用户
★★
Credits 171
Posts 78
Joined 2006-11-22 11:26
19-year member
UID 71373
Gender Male
Status Offline
This is what I did
@RD /q/s %Temp%
@MD %Temp%
It can be realized in XPSP2 and 2003SP1
Floor 9 Posted 2006-11-23 02:37 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Add /A to the 7th floor
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
woof +1 2006-11-23 02:51
Floor 10 Posted 2006-11-23 02:47 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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...



Temporary Internet Files\Content.IE5\9KVUC49T\zh-CN - The process cannot access the file because another program is using it.
Temporary Internet Files\Content.IE5\index.dat - The process cannot access the file because another program is using it.


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 :)

Temporary Internet Files\Content.IE5\index.dat - The process cannot access the file because another program is using it.



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 ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 11 Posted 2006-11-23 02:51 ·  中国 江苏 南京 联通
新手上路
神話
Credits 12
Posts 5
Joined 2006-11-22 21:37
19-year member
UID 71389
Gender Male
Status Offline
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
Floor 12 Posted 2006-11-23 07:05 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Those who can delete index.dat must have really high skills.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 13 Posted 2006-11-23 07:16 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
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)

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 14 Posted 2006-11-23 07:28 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
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?
Floor 15 Posted 2006-11-23 07:32 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
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?
Forum Jump: