Coping part of directory name to another position

A swapping-ground for Regular Expression syntax

Coping part of directory name to another position

Postby theghostofelvis » Wed Jul 06, 2016 11:02 am

Hello!

First of all thank You for this great Tool!

Here is myProblem :

I want to rename my Directories from

Name - Text [typ,year,info,info] to Name year Text [typ,year,info,info] so sorting will be right !

The '-' should be replaced by the year, which is found in the directory name (the - is always betwen spaces, the year is always between 2 ',' and 4 numbers long! The second info tag is not always here but there could be a also a second typ info!

example :

Name - abcdeferr [sddadds,2014,ewrvvegfvvf,yvbvbcb] -> Name 2014 Text [sddadds,2014,ewrvvegfvvf,yvbvbcb]
Name - ewrwrsfwefwer [zuii,tgfgdf,2016,wqxccff] -> Name 2016 Text2 [zuii,tgfgdf,2016,wqxccff]
.....


thanks in advance!
theghostofelvis
theghostofelvis
 
Posts: 3
Joined: Wed Jul 06, 2016 10:18 am

Re: Coping part of directory name to another position

Postby theghostofelvis » Wed Jul 06, 2016 3:18 pm

I think i found the solution :

(.+)(.\-)(.+)(\[)(.*),(\d{4})\,(.+)\]
\1 \6 \3 [\5,\6,\7]
theghostofelvis
 
Posts: 3
Joined: Wed Jul 06, 2016 10:18 am

Re: Coping part of directory name to another position

Postby therube » Wed Jul 06, 2016 4:29 pm

The names have commas like you have shown?
And the year is not necessarily in the same relative ("comma") location within the [ ] ?
(I gather that is not the case, that your examples not representative.)
[Or maybe they are. The way you did it, the search for the comma is greedy, followed by four digits, so it would work regardless of the "position" of the year.]

Your examples show:

2nd.position, if you will:
[sddadds,2014,ewrvvegfvvf,yvbvbcb]
3rd.position:
[zuii,tgfgdf,2016,wqxccff]


You seem to have an extra space in there.
Slight change:
(.+)(.\-)(.+) (\[)(.*),(\d{4})\,(.+)\]
\1 \6\3 [\5,\6,\7]

And another way:
(.* )-(.*)(\d{4})(.*)
\1\3\2\3\4
therube
 
Posts: 374
Joined: Mon Jan 18, 2016 6:23 pm

Re: Coping part of directory name to another position

Postby theghostofelvis » Wed Jul 06, 2016 6:07 pm

thank You!
theghostofelvis
 
Posts: 3
Joined: Wed Jul 06, 2016 10:18 am


Return to Regular Expressions