At first, I know this question probably exists, but on first sight I didn’t find the answer I was looking for.
I’m having a problem creating a batch-file that should delete multiple files with their specific file format given as a parameter. The folder where these files should be is defined as the first parameter. Read-Only, hidden and system files should be deleted too.
So far I have something like this:
CD %1
IF EXIST *.%2 DEL *.%2 /F /A:H /A:S
But this doesn’t has the result it should have…
Can someone help me?
How about…
The
/Dby the CD makes sure it also changes the current drive. By default CD will always stay in the same drive, no matter where you want to go.Then, the
if existis pointless. If there is nothing to delete,DELwon’t delete anything.I’m not sure ifIt is.*.%2is really what you want, because it will only match files with no name with a certain extension. You probably want only%2.If that doesn’t work, please tell us what happens. You told us the expect result, namely that it should delete files in a given directory matching a given pattern. Tell us what happens instead.