• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I remove a number sequence using batch rename

New Here ,
Jun 11, 2014 Jun 11, 2014

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!

TOPICS
Batch , How to

Views

36.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Community Expert , Aug 05, 2016 Aug 05, 2016

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.

Votes

Translate

Translate
Community Expert , Feb 15, 2024 Feb 15, 2024

As long as the pattern of your existing filenames is consistent, these should work.

 

To remove the last _ and the characters after it

gregreser_0-1708017824274.png

 

To change _+ to -  

gregreser_1-1708017994244.png

 

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.

Votes

Translate

Translate
Community Expert , Feb 16, 2024 Feb 16, 2024

@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

 

2024-02-16_22-22-13.png

Votes

Translate

Translate
New Here ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

@Stephen_A_Marsh thanks a lot you are a genius

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

Regular expressions are powerful but can be really difficult to figure out. Good job here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

LATEST

Nice solution @Stephen_A_Marsh 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines