Move date from end to beginning

A swapping-ground for Regular Expression syntax

Move date from end to beginning

Postby Tony316 » Wed Jan 13, 2021 4:04 am

Hello. I have a bunch of mp3 files int the all ending with date like this:
filename_DD_MM_YYYY.mp3
where filename contains other strings seperated with underscores.

I want to move the date in front of the file name like this:
YYYY_MM_DD_filename.mp3

I have searched the forum and I found that you can use Regex with Simple option and write something like:
%1_%2 -> %2_%1,
to change the order of underscore seperated strings in the name of the file.

My problem is that the number of underscores is not the same for all files.
So is there a way to find only the final 3 strings separated by underscores (independent of what there's before those strings)
and move them in the beggining of filename and in the order I want?

I am new to the forum so I sorry if this isn't the right place to ask this question.
Thank you in advance. :)
Tony316
 
Posts: 2
Joined: Wed Jan 13, 2021 3:52 am

Re: Move date from end to beginning

Postby Luuk » Wed Jan 13, 2021 5:08 am

Greetings Tony, with "Simple" it can be like...
%1_%2_%3_%4 -> %2_%3_%4_%1
This because %1 holds everything before the very last three underscores.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Move date from end to beginning

Postby Admin » Wed Jan 13, 2021 5:09 am

Hi, can you give some examples of names with their format, before and after renaming?
thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Move date from end to beginning

Postby Tony316 » Wed Jan 13, 2021 7:21 pm

Greetings Tony, with "Simple" it can be like...
%1_%2_%3_%4 -> %2_%3_%4_%1
This because %1 holds everything before the very last three underscores.


This solves my proble thank you very much.

Hi, can you give some examples of names with their format, before and after renaming?
thanks


In general the have the following format:

NN_NAME_SURNAME_DETAILS_DD_MM_YYYY.mp3 -> NN_YYYY_MM_DD_NAME_SURNAME_DETAILS.mp3,
where NN is number of track and DETAILS may contain underscores in some cases.

But the solution given by Luuk solves this problem, I just didn't notice the way Simple works.

Thank you both for your response.
Tony316
 
Posts: 2
Joined: Wed Jan 13, 2021 3:52 am


Return to Regular Expressions