RegEX for renaming files

Bulk Rename Utility How-To's

RegEX for renaming files

Postby CCarmichael » Wed Jun 21, 2023 4:24 pm

Hi,
I have a whole load of files that need renaming and I was wondering whether there is a place on the forum to request help with the creation of custom RegEXs so that I can do the rename in one go without having to do multiple stages.

The file name structure is generally the following:
Webite name_Date_Title-Model Name (often first name with initial)-by-photographer_62bd5_high

e.g Youtube_2009-06-01_TITLE-PERSON-A-by-INGRET_62bd5_high

And I'm trying to achieve the following using the above example:
[Day-Month] Person A - Title

If this is possible any help would be greatly appreciated, with a slight description so that I can then adapt it according to site, as this would save me time doing this in 3 different steps.

Thank you very much in advance
CCarmichael
 
Posts: 5
Joined: Mon May 16, 2016 2:20 pm

Re: RegEX for renaming files

Postby therube » Wed Jun 21, 2023 7:51 pm

A start...

1:RegEx, enable, Simple
Code: Select all
Match:  %1_%2-%3-%4_%5-%6-%7-%8
Replace:  [%3-%4] %6 %7 - %5

Code: Select all
Youtube_2009-06-01_TITLE-PERSON-A-by-INGRET_62bd5_high
->   [06-01] PERSON A - TITLE

%1 = Youtube
_
%2 = 2009
-
%3 = 06
-
%4 = 01 (don't know if that's month/day or day/month [in this case], so depending, adjust the variables in Replace:)
%5 = TITLE
%6 = PERSON
%7 = A
%8 is everything else

Assuming the %# variables are correctly filled, it's only a matter of rearranging them as you like.

There likely will be gotcha's, as I'm keying in on _ & -, & there is also the assumption that A exists, so if PERSON is "Louis-Dreyfus" (rather then LouisDreyfus), & A is 'J', that is apt to throw things off...
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: RegEX for renaming files

Postby CCarmichael » Mon Jul 31, 2023 4:21 pm

therube wrote:A start...

1:RegEx, enable, Simple
Code: Select all
Match:  %1_%2-%3-%4_%5-%6-%7-%8
Replace:  [%3-%4] %6 %7 - %5

Code: Select all
Youtube_2009-06-01_TITLE-PERSON-A-by-INGRET_62bd5_high
->   [06-01] PERSON A - TITLE

%1 = Youtube
_
%2 = 2009
-
%3 = 06
-
%4 = 01 (don't know if that's month/day or day/month [in this case], so depending, adjust the variables in Replace:)
%5 = TITLE
%6 = PERSON
%7 = A
%8 is everything else

Assuming the %# variables are correctly filled, it's only a matter of rearranging them as you like.

There likely will be gotcha's, as I'm keying in on _ & -, & there is also the assumption that A exists, so if PERSON is "Louis-Dreyfus" (rather then LouisDreyfus), & A is 'J', that is apt to throw things off...


Thanks for this and apologies for the slow reply. With a lot of variables this could be difficult and time consuming.

I can easily get it down to the format of "[Date] Title Person -" and I was wondering whether it be easier to somehow dictate a way to change it to "[Date] Person - Title" where the person is two words in the form of "Firstname A" (where A can be any letter and also a surname).

Is this possible, and thanks again.
CCarmichael
 
Posts: 5
Joined: Mon May 16, 2016 2:20 pm


Return to How-To