Copy link to clipboard
Copied
Hi
I know I've done this in the past but cannot seem to work it out today.
I have a series of images "_####_[layercompName].png". I would like to remove the underscores and numbers. The underscores removal is easy, but how do I remove the numbers (####) when they are different for each filename? I would like the end result to be [layercompName].png
The reason I have these filenames in the first place is that I have run the photoshop script "layer comps to files", and this adds a number sequence prefix. I have tried to alter the script following various instructions I've found from trawling the internet (this one included How do you remove the number sequence when exporting layer comps to files? CS6. Windows 8.) but without any luck. So now I'm resorting to batch renaming in Bridge.
Thanks!
3 Correct answers
If you are referring to the “code” that is typed in once the “use regular expression” checkbox has been ticked:
Regular expression - Wikipedia, the free encyclopedia
Also known as GREP or RegEx for short.
As long as the pattern of your existing filenames is consistent, these should work.
To remove the last _ and the characters after it
To change _+ to -
Click the Preview button to confirm everything is correct, including the file extention, before you run it. Also, select the "Preserve current filename in XMP" option so you can revert back in case there is a problem.
@yuri5 – I like the answer from @gregreser – however, here is another equivalent method for the regular expression find and replace using capture groups:
Find:
(^.+?\+)(.+)(-)(.+)(_\+)(.{2})(.+)(\.[^\.]+$)
Or perhaps "better", Find:
(^.+?\+)(.+)(-)(.+)(_\+)(.+)(_.+)(\.[^\.]+$)
Replace with:
$2_$4-$6$8
Copy link to clipboard
Copied
@Stephen Marsh thanks a lot you are a genius
Copy link to clipboard
Copied
Regular expressions are powerful but can be really difficult to figure out. Good job here.
Copy link to clipboard
Copied
Nice solution @Stephen Marsh


-
- 1
- 2