Batch file to delete directories

Custom / CUSTOM
January 24, 2011 at 08:49:49
Specs: Windows 7, 2.133 GHz / 2046 MB
Hi,

I'm looking for a batch file that will scan my music folder and delete all directories and contained files when the directory name contains the word 'files'. For example i have a music folder set like this:
My Music/
The Beatles/
White Album/
track 1.mp3
track 1.mp3.files/
vcm_s_kf_m160_160x158.jpg
vcm_s_kf_repr_500x496.jpg

The Sony home network program introduced all these extra files that are a waste of space, i've uninstalled the program but just need a fast way to get rid of these waste files. Can anybody help please?

Regards

Rizla


See More: Batch file to delete directories

Report •


#1
January 24, 2011 at 08:54:05
It would look like CD c:\ Documents and Settings\Your Name\My Music
del /q *.file
exit

Report •

#2
January 24, 2011 at 09:04:58
Untested:
for /r "%UserProfile%\Documents\My Music" /d %%a in (*.files) do rd /s /q "%%~Fa"

How To Ask Questions The Smart Way


Report •

#3
January 24, 2011 at 09:52:07
I should have stated that the path to my music collection is F:\My Documents\My Music also the directories have the hidden and read only attributes set on them. I tried each of your methods but the files are still there. Am i doing something wrong?

Regards

Rizla


Report •

Related Solutions

#4
January 24, 2011 at 12:43:27
I should have stated . . .
Yes, you should have.

Still untested:

for /f "delims=" %%a in ('dir /s/b/ad "F:\My Documents\My Music\*.files"') do rd /s /q "%%~Fa"

EDIT: How'd my command prompt get in there?
How To Ask Questions The Smart Way


Report •

#5
January 24, 2011 at 21:53:00
The system cannot find the drive specified.

Report •

#6
January 25, 2011 at 09:00:46
Thanks Razor2.3, that's got it now.

Regards

Rizla


Report •

Ask Question