A simple regular expression that does not work

A swapping-ground for Regular Expression syntax

A simple regular expression that does not work

Postby hugozam » Thu Jun 26, 2014 1:46 am

Can any body tell me what is wrong. Either it is nor previewing or the regular expression is wrong or there is a setting I am missing. I did not see a way to upload the screen shot and simply pasting the screen shot did not pate any thing, sorry.

The idea is to change bad-date-named folders (produced by PlayMemories Home) of this style

1-30-2014 to 2014-01-30
1-10-2014 to 2014-01-10
1-2-2014 to 2014-01-02
11-3-2014 to 2014-11-03

which looks very simple. So I am using:

RegEx
Match: (.)-(..)-(....)
Replace: \3-0\1-\2

but does not preview any change at all. I understand that to preview I have to select the items I want to transform in the "Name" column.

I also tried:

Match: (\d)-(\d\d)-(\d\d\d\d)
Replace: \3-0\1-\2

and

Match: (\d).(\d\d).(\d\d\d\d)
Replace: \3-0\1-\2

and

Match: ([0-9])-([0-9][0-9])-([0-9]{4})
Replace: \3-0\1-\2

Nothing works. I am using the 64-bit version 2.7.1.2
Last edited by hugozam on Sun Jun 29, 2014 6:56 pm, edited 1 time in total.
hugozam
 
Posts: 5
Joined: Thu Jun 26, 2014 12:40 am

Re: A simple regular expression that does not work

Postby truth » Fri Jun 27, 2014 2:24 pm

The 1Regex checkbox might be unchecked.

OrigNames might have Unicode-chars (that regex wont match)
To confirm, you can try:
(.*)
--\1--

Any non-matchable names would confirm that suspicion
If you have a CharTrans to convert the problem Unicode(s)
you can run it with 1Regex, since CharTrans runs beforehand.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: A simple regular expression that does not work

Postby hugozam » Sun Jun 29, 2014 5:47 pm

RegEx check box is on, for sure. I just created one plain file name and another subdirectory in Win-7 manually to prevent any weird character in the names and it does not do any conversion. I did try your test and it does not convert any thing.

At one point it did convert to 000001, 000002, etc but that was because "Numbering" was checked. I have "Foders" and "Files" checked as I want both to convert.
hugozam
 
Posts: 5
Joined: Thu Jun 26, 2014 12:40 am

Re: A simple regular expression that does not work

Postby hugozam » Sun Jun 29, 2014 6:18 pm

I found what the problem was: "File (2)" was checked and it was set to "Remove". I changed it to "Keep" and it is now converting fine. Actually I am going to uncheck it. I will read more to find out what that option is for.
hugozam
 
Posts: 5
Joined: Thu Jun 26, 2014 12:40 am

Re: A simple regular expression that does not work

Postby hugozam » Sun Jun 29, 2014 6:54 pm

So the solution for those that have a problem accepting the way PlayMemories Home names subdirectories when importing videos is to create four transformations as follows. Uncheck all the BRU groups except for "RexEx (1)". If somebody has a way to merge these four transformations into one please let me know.

first:
^([0-9]{1})-([0-9]{1})-([0-9]{4})$
\3-0\1-0\2


second:
^([0-9]{1})-([0-9]{2})-([0-9]{4})$
\3-0\1-\2


third:
^([0-9]{2})-([0-9]{1})-([0-9]{4})$
\3-\1-0\2


fourth:
^([0-9]{2})-([0-9]{2})-([0-9]{4})$
\3-\1-\2


Note: It seems that the videos folders are correctly named inside the flash memory before importing, so another alternative is to go into the flash memory and copy and paste the directories into your PC and not use PlayMemories import option.
hugozam
 
Posts: 5
Joined: Thu Jun 26, 2014 12:40 am

Mandate 2Digit Months/Days

Postby truth » Mon Jun 30, 2014 8:36 am

Not familiar with PlayMemories, but I wouldnt use 'import' unless that function
also bundles something besides just moving/copying files that's also needed.

Note: ALL non-1Regex setting have the ability to modify NewName after 1Regex
Keeping this strictly within regex, I would:

Run1: Get proper ordering, with mandated leading-zeros:
^([1-9][0-2]{0,1})-([1-9]\d{0,1})-(\d{4})$
\3-0\1-0\2

Run2: Kill unnecessary leading-zeros:
^(\d{4})-0*(\d{2})-0*(\d{2})$
\1-\2-\3

OrigName ---> NewName
1-2-2014 ---> 2014-01-02
1-10-2014 --> 2014-01-10
1-30-2014 --> 2014-01-30
11-3-2014 --> 2014-11-03


No single regex can handle this, because theres no conditional-replace.
Once 0 goes into the replacement, 0 must become part of NewName.
The only exception would be non-matched names (requiring another regex).

Note the commandline version handles this in a single-run,
since it can process multiple regexes before each rename.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions