Computing.Net > Forums > Programming > Batch del files and folder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch del files and folder

Reply to Message Icon

Name: Shilee
Date: June 19, 2008 at 19:26:14 Pacific
OS: win xp
CPU/Ram: 3.2/512
Product: dell
Comment:

I wanna delete all files and sub folders in the folder. Any1 can help?



Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: June 19, 2008 at 22:58:52 Pacific
Reply:

One method is to delete the folder and then recreate it.


0

Response Number 2
Name: Shilee
Date: June 19, 2008 at 23:24:03 Pacific
Reply:

I thought about it too but after del and recreate it, I have to add permission for users of this folder again, so I dont wanna do it.
any1 can help?


0

Response Number 3
Name: toast (by NoIdea)
Date: June 20, 2008 at 01:19:54 Pacific
Reply:

Is this what you want?

RD C:\Path /S /Q
RMDIR C:\Path /S /Q

/S = Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.
/Q = Quiet mode, do not ask if OK to remove a directory tree with /S.


0

Response Number 4
Name: Shilee
Date: June 20, 2008 at 01:24:18 Pacific
Reply:

no, I only want delete files and sub folders in this folder not delete this folder


0

Response Number 5
Name: toast (by NoIdea)
Date: June 20, 2008 at 02:15:11 Pacific
Reply:

Possibly?

C:\>cd \Your main\Next
So now in
C:\Your main\Next>rd Your file /s


0

Related Posts

See More



Response Number 6
Name: IVO
Date: June 20, 2008 at 03:03:24 Pacific
Reply:

@echo off
del "Your_Folder\*.*" /Q
for /f "tokens=* delims=" %%j in ('dir "Your_Folder" /B /AD') do (
RD "%%j" /S /Q)


0

Response Number 7
Name: Shilee
Date: June 22, 2008 at 20:44:27 Pacific
Reply:

ty IVO
I used ur script but it only delete files in the folder, all subfolders and files in those subfolders still remain
any1 can help?


0

Response Number 8
Name: IVO
Date: June 23, 2008 at 05:41:40 Pacific
Reply:

Sorry, my mistake, try again using the below fixed version

@echo off
del "Your_Folder\*.*" /Q
for /f "tokens=* delims=" %%j in ('dir "Your_Folder" /B /AD') do (
RD "Your_Folder\%%j" /S /Q)


0

Response Number 9
Name: Shilee
Date: June 23, 2008 at 20:30:59 Pacific
Reply:

tyvm IVO
it worked fine


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch del files and folder

rename files and folder to lowercase with b www.computing.net/answers/programming/rename-files-and-folder-to-lowercase-with-b/19161.html

Enumerate all files and folders www.computing.net/answers/programming/enumerate-all-files-and-folders/9618.html

hiding picture files and folders www.computing.net/answers/programming/hiding-picture-files-and-folders/3886.html