Recently I have written a simple BAT file to delete all unnecessary *.RES files from the current directory and its sub-directories:
del /S "*.res"
But it deleted all *.RESX files in addition too (ooh, my luckless C# projects ...).
I understand that it converted all filenames to DOS 8.3 format before, so any file like "Resources.resx" will have DOS 8.3 filename "resour~1.res", so it will match the pattern "*.res" unfortunately.
Question: is there simple way to force the batch file to consider the complete filenames, not 8.3 filenames?
At least to 'say' that the length of file extension should be 3 characters exactly.
It's because the
dir
in cmd.exe uses theFindFirstFile
API due to legacy issues. That API matches both long and 8.3 names, hence *.res and *.resx would be the sameThe simplest solution is to use powershell
It can be called from cmd like this (here I replaced the cmdlets with their common aliases):
The pure batch solution would be more cumbersome