#1 2019-11-30 07:44

stivgross
Member
From: Kauai
Registered: 2019-11-30
Posts: 2

Trying to change '- 1974 -' to [1974] in folders for mp3's

Hi,
I would like to change my music file folder structure as follows:

I would like to look for a 'dash, space, 4 digit number, space, dash- and change the "dashes" to brackets "[   ]"

For example:
Antônio Carlos Jobim - 1974 - Urubu [1995 Warner]

would become:
Antônio Carlos Jobim [1974] Urubu [1995 Warner]

It would be great if I could specify that the 1st two digits of the 4 digit number be "19" or "20"
I've been playing around with it in the preview pane without much success.

If someone would show me how to do this it would really be appreciated!

Offline

#2 2019-11-30 11:44

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 322

Re: Trying to change '- 1974 -' to [1974] in folders for mp3's

Hi stivgross,

stivgross wrote:

I would like to look for a 'dash, space, 4 digit number, space, dash- and change the "dashes" to brackets "[   ]"
...
It would be great if I could specify that the 1st two digits of the 4 digit number be "19" or "20"

Add this RegEx to Regular Expressions rule:

1) Regular Expressions: Replace expression "(.+) - ((19|20)\d{2}) - (.+)" with "$1 [$2] $4"

From:
Antônio Carlos Jobim - 1974 - Urubu [1995 Warner]

To:
Antônio Carlos Jobim [1974] Urubu [1995 Warner]

Is this works for you?


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#3 2019-11-30 11:45

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 2,856

Re: Trying to change '- 1974 -' to [1974] in folders for mp3's

Regular Expressions to the rescue!

Replace expression "- ((19|20)\d\d) -" with "[$1]" (skip extension)

Input:
Antônio Carlos Jobim - 1974 - Urubu [1995 Warner]

Output:
Antônio Carlos Jobim [1974] Urubu [1995 Warner]

See the user manual for additional information:
https://www.den4b.com/wiki/ReNamer:Regular_Expressions

Offline

#4 2019-11-30 19:49

stivgross
Member
From: Kauai
Registered: 2019-11-30
Posts: 2

Re: Trying to change '- 1974 -' to [1974] in folders for mp3's

Those both work great - Thank you so much.  The (.+) is probably not needed in my case, but nice to know what it can do.
I am going to spend some time going over the wiki, it seems that understanding "RegEx" is quite useful for writing/debugging programs.
I need to learn basic programming because I ordered an Arduino board for my 12 year old daughter for Christmas.  I'm decent with hardware but never really learned how to code.  She wants to be a "youtuber", but I want her to get into HW/SW as a backup plan.

eR@SeR - Not sure if you're a football fan, but good luck in the 2020 Euro playoffs.  I have a Branislav Ivanović #6 national team shirt that I wear when I watch Serbia play.  He and Didier Drogba are my favorite players of all time (I'm a Chelsea fan).  Bane is still playing well at 35 with Zenit.

Thanks Again!

Offline

#5 2019-12-02 00:17

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 322

Re: Trying to change '- 1974 -' to [1974] in folders for mp3's

stivgross wrote:

The (.+) is probably not needed in my case, but nice to know what it can do.

As per the given example it works. It won't work well if there are multiple year occurrences or if there is no text on the left or right side of "- yyyy -"  (19 or 20 starting years) part.

Solution provided by den4b will find all "- yyyy -" (19 or 20 starting years) occurrences and replace them, no matter what's on the left or right side.

It depends on what patterns you want to match.

These solutions are good to see what RegEx is capable of and design it as per your needs. To create narrow (find more specific pattern) or wider one... For example when I was looking for RegEx to validate a date I couldn't believe that someone made it work with leap years yikes They are really powerful!

stivgross wrote:

eR@SeR - Not sure if you're a football fan, but good luck in the 2020 Euro playoffs.  I have a Branislav Ivanović #6 national team shirt that I wear when I watch Serbia play.  He and Didier Drogba are my favorite players of all time (I'm a Chelsea fan).  Bane is still playing well at 35 with Zenit.

Thank you. It will be hard to qualify. Luck is what we need the most smile
Nice to know that we have a non-Serbian fan smile


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

Board footer

Powered by FluxBB