75lb/renamer

Regex issue with Git Bash on Windows

Closed this issue · 5 comments

image

I am not sure if I am doing something wrong or regex is not working. I am trying to add prefixes to all the files in that folder. but this doesn't seem to work.

image

I used the example in your doc. but this is also not working.

75lb commented

Works for me (see below).. which OS are you on? Windows? Which shell are you using?

$ renamer --find /0/ --replace="Hello - " --verbose --dry-run *

Dry run

✔︎ 01.jpg → Hello - 1.jpg
✔︎ 02.jpg → Hello - 2.jpg
✔︎ 03.jpg → Hello - 3.jpg

Rename complete: 3 of 3 files renamed.
75lb commented

The same test as above also worked correctly in the Windows default shell (cmd).. However, it didn't work in Git Bash shell (cygwin), I will look into that.. which shell are you using?

75lb commented

for some reason, on Git Bash, the shell inteprets /1/ to mean the file 1 in the Git folder.. e.g. if you run this it will print the license from the C:\Program Files\Git folder

cat '/LICENSE.txt'

That is not the expected behaviour.. oh well..

You can work around this issue by escaping the first backslash in the find expression (i.e. --find "\/0/").. i'm not sure how to fix this long-term as I can't control what Git Bash passes into renamer..

Thanks for looking into this. I am using Git Bash on windows. escaping the first backslash solves the problem.