Skip to main content
Participant
Sep 21, 2020 4:58 PM UTC
Answered

Filename string substitution: rename and reorder elements using RegEx

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.

This topic is closed to new replies. Start a new post to keep the conversation going.
Stephen Marsh
Stephen MarshCorrect answer
Community Expert
Sep 22, 2020 10:59 PM UTC

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

 

 

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.

4 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
Sep 22, 2020 10:59 PM UTC

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

 

 

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.

Translate
Participant
Sep 28, 2020 10:12 PM UTC

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

Translate
Stephen Marsh
Community Expert
Community Expert
Sep 21, 2020 8:35 PM UTC

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

Translate
Legend
Sep 21, 2020 7:49 PM UTC

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.

Translate