I don't understand why findstr
doesn't work as I want.
I have the following files in my test directory:
aaa.jpg
bbb.png
ccc.svg
aaa_s.jpg
bbb_s.png
ccc_s.svg
aaa_small.jpg
bbb_small.png
ccc_small.svg
And I have the following line to pass directly to cmd.exe:
for /f "delims=" %f in ('dir /b /a:-d ^| findstr /ile "gif jpg png svg" ^| findstr /ie "_s.*"') do echo "%f"
To my opinion, it should match the following files:
aaa_s.jpg
bbb_s.png
ccc_s.svg
However, it's actually matches
aaa_s.jpg
bbb_s.png
ccc_s.svg
aaa_small.jpg
bbb_small.png
ccc_small.svg
Yes, I understand that the problem is that the dot works as "any character" instead of being treated literally.
findstr /ie "_s.*"
Bot how can I escape it? Using backslash, i.e. changing it to
findstr /ie "_s\.*"
doesn't work.
.
is in fact escaped with\
, according to this post serverfault.com/questions/123483/…. Is there something else wrong with your script? Btw nobody understands howfindstr
works :) It seems that David already answered, so there you go