I have a tree of directories containing files and sometime a copy at the same location. This copy is identified by some string, e.g. _001
, appended to the original file name.
somefile.txt
andsomefile_001.txt
I can list such files at the DOS prompt using:
dir /s *_001.*
or
for /f "tokens=1,2 delims=_" %i in ('dir /s /b *_*.*') do echo %i_%j
But I don't know if this is possible, likely using the later format, to check whether the original file exists and in this case delete the copy.