Probably far too easy question, but how do I match a file extension such as .jpg while not matching jpg~ (i.e. a jpg that a program has made a local copy of?) My current line is:
for /f %%a in ('dir /b *.jpg') do echo %%~na
But if any program has a copy of one of the files open (and thus has made a .jpg~ file) this regexp will match those too. I found a reference to $ being the ‘end of line’, but doing this doesn’t work at all:
for /f %%a in ('dir /b *.jpg$') do echo %%~na
I don’t think it is possible to filter this with just a FOR command (unless you pipe the output of dir to findstr) but in this case, adding a simple if test is all that is needed: