regex assistance - move trailing - YYYY

A swapping-ground for Regular Expression syntax

regex assistance - move trailing - YYYY

Postby gyuszi » Fri Nov 21, 2014 4:30 pm

Hello all! And thanks in advance for any help provided.

This is the scenario; I have a bunch of music directories that I would like to rename. Most have the release year at the end. However this does not help with chronilogical sorting.

I would like to move the year from the end of the file name to right after the artist name.

Most files originaly : Pink Floyd - DSOTM - 1973

What I would like : Pink Floyd - 1973 - DSOTM

So basically, what I am thinking I need is to take the last 7 spaces, which would be constant for each file name irrespective of length (" - 1973") and move it to just before the first dash which would give me the spacing needed.

That should give me what I want, no? I have tried several of the built in functions without luck.

Any help in writing an exporession would be very much appreciated.
gyuszi
 
Posts: 3
Joined: Fri Nov 21, 2014 4:20 pm
Location: New Orleans, LA - USA

move YYYY part swap order reorder rearrange regex

Postby Stefan » Fri Nov 21, 2014 8:20 pm

FROM:
Pink Floyd - DSOTM - 1973.ext

TO:
Pink Floyd - 1973 - DSOTM.ext

RULE:
- Match everything until before first Space-Hyphen, and store as $1, Pink Floyd
- Match everything until before second Space-Hyphen, and store as $2, - DSOTM
- Match the rest, and store as $3, - 1973

USE:

RegEx(1)
Find: (.+?)( - .+?)( - \d\d\d\d)
Repl: \1\3\2

OR:

RegEx(1)
Find: (.+?) - (.+?) - (\d\d\d\d)
Repl: \1 - \3 - \2

OR:

RegEx(1)
Find: (.+?) - (.+?) - (\d{4})
Repl: \1 - \3 - \2

OR:

RegEx(1)
Find: (.+) - (.+) - (.+)
Repl: \1 - \3 - \2


The different between that solution are only academical, choose what you like. The matching and the result are always identical.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: regex assistance - move trailing - YYYY

Postby gyuszi » Fri Nov 21, 2014 8:26 pm

Stefan - Many thanks for the speedy reply!

I will test this out later tonight. You can't imagine how helpful you have been. :D
gyuszi
 
Posts: 3
Joined: Fri Nov 21, 2014 4:20 pm
Location: New Orleans, LA - USA

Re: regex assistance - move trailing - YYYY

Postby gyuszi » Sat Nov 22, 2014 5:16 am

SUCCESS!!!

Many thanks for your generous help.

May you & yours have a wonderful and prosperous 2015 and beyond. :mrgreen:
gyuszi
 
Posts: 3
Joined: Fri Nov 21, 2014 4:20 pm
Location: New Orleans, LA - USA

Re: regex assistance - move trailing - YYYY

Postby Stefan » Sat Nov 22, 2014 10:35 am

Same to yours and thanks for the feedback!
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions