I'm trying to write a Windows Batch Script file that deletes just .asp files.
If I do:
del *.asp /s
This has the side-effect of deleting any files with the extension .aspx. This is bad because I want to preserve files with the aspx extension.
Is there any solution to this problem that doesn't require installing a custom application?
This seems to do the trick on Vista:
For more information
There are all kinds of modifiers to variables:
I suspect that because del is a DOS-vintage command, it doesn't understand extensions longer than 3 characters.
There are several solutions I can see, only one of which you'll like and none of which fits your exact requirements:
Powershell will do this. While
dir -r *.asp
will match*.aspx
, you can easily refine the output:Using
-include
to match wildcards in PSH rather than-filter
(normally faster) which matches with the Win32 API (with the same results ascmd.exe
).You presumably only want to delete files, so, for testing:
Use of
-whatif
to just list what would happen. Use-confirm
to prompt to configurm the file deletes. For use in a scrip avoiding aliases, but listing what is done: