delete certain files using batch

December 19, 2010 at 18:06:15
Specs: dos
hi i have a folder that contains pdf files and files with extension pdf<date> i want to delete the later. for example
abc.pdf
abc.pdf101220
i just want to keep files with the .pdf extension is there a dos batch i can use? thanks

See More: delete certain files using batch

Report •


#1
December 19, 2010 at 18:50:46
you might try:
del *~*.pdf

but you might want to back up the entire directory first. It worked on mine, but
your 8-dot-3 settings might be different and yield different (undesirable) results.


Report •

#2
December 19, 2010 at 21:53:40
hi no the pdf101220 is part of the extension. its not a normal 8.3 file name

Report •

#3
December 20, 2010 at 04:24:00
Nothing to do with DOS..What OS?


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
December 20, 2010 at 04:44:57
sorry yes im running win server 2003

Report •

#5
December 20, 2010 at 05:34:42
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s *.pdf*') do (
if %%~Xa neq .pdf del %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#6
December 20, 2010 at 05:41:13
thanks so much mechanix it works great

Report •

#7
December 20, 2010 at 05:45:54
also is there something i can put in to make it find files in subfolders too?

Report •


Ask Question