Computing.Net > Forums > Programming > Batch file to delete folder in fol.

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 file to delete folder in fol.

Reply to Message Icon

Name: mumdaven
Date: September 19, 2008 at 07:10:56 Pacific
OS: xp
CPU/Ram: c2
Comment:

This is an example of a batch file I am using right now. I need it to delete subfolders in the folders. It already deletes everything else, just not folders. I am not sure what extra code lines I need to add for it to delete folders.

Here is the code I am using.

:folder
c:
cd C:\folder
del *.* /s /q
goto thing

:thing
c:
cd \
cd C:\thing
del *.* /s /q
goto yeah

:yeah
cd \
cd C:\yeah
del *.* /s /q
goto yep


:yep
cd \
cd C:\yep
del *.* /s /q

:FINISH
endlocal



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 19, 2008 at 07:27:45 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for %%F in (folder thing yeah yep) do (
pushd c:\%%F

for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
rd /s /q %%a
)
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: mumdaven
Date: September 19, 2008 at 08:12:01 Pacific
Reply:

Not getting this to work. I am brand new at scripting. Just kinda made this one off other people. Not sure how that fits into my file format.


0

Response Number 3
Name: Mechanix2Go
Date: September 19, 2008 at 08:47:17 Pacific
Reply:

any errors ?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: AlbitzT
Date: September 24, 2008 at 18:42:23 Pacific
Reply:

Why not just replace 'del *.* /s /q ' with 'RD /S /Q'

That will remove all the files in the directory and sub-directory, as well as remove the directory and sub-directories.


0

Response Number 5
Name: Mechanix2Go
Date: September 24, 2008 at 19:09:03 Pacific
Reply:

uh... right

I thought that's what I said.


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



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 file to delete folder in fol.

Batch file to delete files in a dir www.computing.net/answers/programming/batch-file-to-delete-files-in-a-dir/14599.html

Batch File to open and move .ttf fi www.computing.net/answers/programming/batch-file-to-open-and-move-ttf-fi/12043.html

batch file to delete www.computing.net/answers/programming/batch-file-to-delete/15614.html