# Solved: Batch file to delete all .xxx files from a file



## LostinKansas (Feb 25, 2010)

I am wondering how to write a script that would delete all files of a certain extension from a folder.


----------



## TheOutcaste (Aug 8, 2007)

I'm guessing you mean all files of a certain extension from a *folder*?
Just use a wild card for the name and specify the extension:
*Del *.xxx*


----------



## LostinKansas (Feb 25, 2010)

Yes sorry from a folder is what i meant... how would i direct it to a specific folder though? Lets say i wanted to delete all .pdf files in the C:\Documents and Settings\All Users\Desktop each time i ran the bat file.


----------



## TheOutcaste (Aug 8, 2007)

Use either of these in the file:
Del /Q "C:\Documents and Settings\All Users\Desktop\*.pdf"

Del /Q "%ALLUSERSPROFILE%\Desktop\*.pdf"

The /Q means it won't prompt for verification. The %ALLUSERSPROFILE% variable expands to the All Users profile folder even if it's on another drive, say if Windows is installed on drive D: on some systems.


----------



## LostinKansas (Feb 25, 2010)

Works perfect! Thank you for your help Outcaste!

-not so LostinKansas anymore


----------

