#1 : 12/05-20 18:44 mankie
Posts: 1
|
Hi,
I have thousands of files i need to replace and I'm having an issue where it's replacing things i don't want to replace. Below is an examples. example of file names; 5443-110-4533-1.png 5443-110-4533-12.png 5443-110-4533-123.png 5443-110-4533-1_c.png 5443-110-4533-2.png I need help to replace the last number and dash "-1" with _black, but at the same time, it should not replace -12 with _black2.png or -123 with _black23.png, but should replace -1_c with _black_c. Thank you |
#2 : 12/05-20 23:52 David Lee
Posts: 1125
|
Replace method
Text to be replaced: .*-.*-.*\K-\d([^\d]|$) Replace with: _black\1 Occurrence: 1st Use regular expressions This works with all your examples but assumes that the "-1" you wish to replace is always the 3rd dash in the filename. |
#3 : 13/05-20 17:24 David Lee
Posts: 1125
|
Reply to #2:
Sorry - I posted the wrong regular expression. That one will replace a hyphen followed by ANY single digit with "_black" so 5443-110-4533-2 -> 5443-110-4533_black To replace ONLY "-1" use: .*-.*-.*\K-1([^\d]|$) |