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

Filename string substitution: rename and reorder elements using RegEx

New Here ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

I am trying to understand the RegEx syntax to accomplish a limited scope of rename/reorder operations for migration to a new MAM/storage system. I have thousands of files with file names resembling the following:

HS - 3_1_18_1pm_Jerry Garcia

and need to identify and reorder the date/time string from the existing M_DD_YY_Ttt format seen above to the new format of:

YYYY_MM_DD

and then possibly rearrange the different elements of the filename.

 

I have used Bridge extensively in the past for basic find/replace and sequencing jobs, but I have been unable to find a good primer on the RegEx syntax for advanced string substitution. Please advise.

TOPICS
Batch , How to , Scripting

Views

511

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 1 Correct answer

Community Expert , Sep 22, 2020 Sep 22, 2020

Presuming that the year should be changed from 18 to 2018, one method would be to use Bridge's Batch Rename as follows:

 

Find:

(^.+ - )(\d+)(_)(\d+)(_)(\d+)(_.+)(_)(.+)

 

Replace:

$120$6_$2_$4$7_$9

 

capture-groups.png

 

Of course, it will not be that easy, as you probably also wish to pad out single D and M values to be DD and MM as well as the presumed 20 padding before the year to make YY into YYYY.

Votes

Translate

Translate
LEGEND ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

I'm not sure a regex is the way to go. Writing a script might work better since you are trying to parse the filename.

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 ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Please provide at least three full before and after examples including 1 and 2 digit date examples.

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 ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

Presuming that the year should be changed from 18 to 2018, one method would be to use Bridge's Batch Rename as follows:

 

Find:

(^.+ - )(\d+)(_)(\d+)(_)(\d+)(_.+)(_)(.+)

 

Replace:

$120$6_$2_$4$7_$9

 

capture-groups.png

 

Of course, it will not be that easy, as you probably also wish to pad out single D and M values to be DD and MM as well as the presumed 20 padding before the year to make YY into YYYY.

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
New Here ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

LATEST

Thanks you @Stephen_A_Marsh , that helps me greatly! I have also found RegEx Coach in the interim of these posts.

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