Subject: Re: [Name Mangler Talk] date: from D/m/Y to Y/M/D ?

From: gruff owen <[email-masked]>
Date: Thu, 16 Aug 2012 21:54:36 +0100

Brilliant, thanks Rob.

On 14 Aug 2012, at 23:22, Rob Griffiths wrote:

> On Aug 14, 2012, at 2:22 PM, gruff owen wrote:
> 
>> Hi Rob,
>> what I want to do is rename folders with names such as :
>> 13 August 2012 to become 2012-08-13
>> 27 May 2012 to become 2012-05-27
>> 
>> Is that enough for you or do you need more examples?
> 
> Here's a version of the previously-posted code that should work with English names -- see my screenshot below with your two sample filenames:
> 
> [concatenate
> 	[findRegularExpression
> 		"^(\d{1,2})\s+([A-Za-z]+)\s+(\d{4})$"
> 		in <name>
> 		replace with "$3"
> 	],
> 	"-",
> 	[findRegularExpression
> 		[concatenate
> 			".*(\d{2})",
> 			[findRegularExpression
> 				"^(\d{1,2})\s+([A-Za-z]{3})\w*\s+(\d{4})$"
> 				in <name>
> 				replace with "$2"
> 			],
> 			".*"
> 		]
> 		in "01Jan 02Feb 03Mar 04Apr 05May 06Jun O7Jul 08Aug 09Sep 10Oct 11Nov 12Dec"
> 		replace with "$1"
> 	],
> 	"-",
> 	[findRegularExpression
> 		"^.*(\d{2})$"
> 		in [concatenate
> 			"0",
> 			[findRegularExpression
> 				"^(\d{1,2})\s+([A-Za-z]+)\s+(\d{4})$"
> 				in <name>
> 				replace with "$1"
> 			]
> 		]
> 		replace with "$1"
> 	],
> 	[if
> 		<extension>
> 	then
> 		[concatenate ".", <extension>]
> 	else
> 		""
> 	]
> ]
> 
> PLEASE PLEASE PLEASE test on a copy of your data, or dummy empty folders, and make sure you have a current backup, just in case things go wrong.
> 
> regards,
> -rob.
> 
> ------------------------------------------
> 
> -- 
> You received this message because you are subscribed to the Name Mangler Talk group. To post to this group, send email to [email-masked]. To unsubscribe from this group, send email to [email-masked].
> 
> For more options, visit the Name Mangler Talk web page at <http://groups.google.com/group/name-mangler-talk>

---

From: Rob Griffiths <[email-masked]>
Date: Tue, 14 Aug 2012 15:22:50 -0700

[concatenate
	[findRegularExpression

regards,
-rob.

---

From: gruff owen <[email-masked]>
Date: Tue, 14 Aug 2012 22:22:35 +0100

Hi Rob,

Many thanks

Gruff

On 01/08/12 19:21, Rob Griffiths wrote:
> On Jul 26, 2012, at 1:49 PM, doughboy wrote:
>
>> this is exactly what I'm looking for to perform the same task but I can't get it to work on English month names, what would I need to alter to make it work on "1 Dec 2010" for example?
> Can you send me a list of example filenames, showing the before and desired-after names?
>
> thanks;
> -rob.
>

---

From: Rob Griffiths <[email-masked]>
Date: Wed, 1 Aug 2012 11:21:23 -0700

thanks;
-rob.

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 18 Dec 2011 07:47:15 -0800

On Dec 12, 2011, at 7:32 AM, gregol wrote:

> It worked like a charm! I owe you one!

Don't worry about it.

> Do you have an Amazon wish list? Or something similar where I could
> offer you a christmas present?

Don't worry about it ... just ...

> Of course I am also buying Name Mangler and Moon!

... do that, and that'd be thanks enough!

> PS: I am sure this script can be used by others, because the bad
> folder naming was made by an old version of iPhoto and I can't be the
> only one! Can I ? ;)

So far, you're the only one. But we'll keep it around in case the question comes up again.

regards,
-rob.

---

From: gregol <[email-masked]>
Date: Mon, 12 Dec 2011 07:32:07 -0800 (PST)

Take good care,
G

---

From: Rob Griffiths <[email-masked]>
Date: Mon, 12 Dec 2011 06:34:53 -0800

On Dec 11, 2011, at 1:48 PM, gregol wrote:

> But, of course, if the challenge is your motivation ;)
> All the possible versions of folders are the one I gave earlier:

Peter replies:

I understand there's only ever one "_(number)" suffix in any given folder name. If that's the case, then this should work...

1) TEST ON A COPY OF YOUR FOLDERS!!!!
2) SEE #1!!!

With that out of the way, get Name Mangler set with your files listed on the left, and then go to Advanced mode. Replace everything there with the following code:

[if
	[findRegularExpression
		"^(\d{1,2})(_\d+)?\s+([^_|\.]+)(_\d+)?\.?\s+(\d{2})(_\d+)?$"
		in <name>
		replace with ""
	]
then
	""
else
	[concatenate
		"20",
		[findRegularExpression
			"^(\d{1,2})(_\d+)?\s+([^_|\.]+)(_\d+)?\.?\s+(\d{2})(_\d+)?$"
			in <name>
			replace with "$5"
		],
		"-",
		[findRegularExpression
			[concatenate
				".*(\d{2})",
				[findRegularExpression
					"^(\d{1,2})(_\d+)?\s+([^_|\.]+)(_\d+)?\.?\s+(\d{2})(_\d+)?$"
					in <name>
					replace with "$3"
				],
				".*"
			]
			in "01janv 02févr 03mars 04avr 05mai 06juin 07juil 08août 09sept 10oct 11nov 12déc"
			replace with "$1"
		],
		"-",
		[findRegularExpression
			"^.*(\d{2})$"
			in [concatenate
				"0",
				[findRegularExpression
					"^(\d{1,2})(_\d+)?\s+([^_|\.]+)(_\d+)?\.?\s+(\d{2})(_\d+)?$"
					in <name>
					replace with "$1"
				]
			]
			replace with "$1"
		],
		[findRegularExpression
			"^(\d{1,2})(_\d+)?\s+([^_|\.]+)(_\d+)?\.?\s+(\d{2})(_\d+)?$"
			in <name>
			replace with "$2$4$6"
		],
		[if
			<extension>
		then
			[concatenate ".", <extension>]
		else
			""
		]
	]
]

There's a screenshot showing how it worked in Peter's testing at the end of this note. Hopefully it works for you, too -- but as noted, please please please test on a copy of your folders!

-rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 13:48:24 -0800 (PST)

I can also simplify on my side and separate the _02 and _03 in
separate parent folders and erase the _02 and _03 with a separate
action.

A. "29 juil. 09"  (abbreviated)
B. "14 août 09" (full)
C. "20 sept_2. 09" (abbreviated,  "_numbers") (the position of the
"_numbers" was a bug from the app with the abbreviations)
D. "18 août 09_2" (full,  "_numbers")

best,
G

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 11 Dec 2011 11:45:16 -0800

On Dec 11, 2011, at 10:49 AM, gregol wrote:

> Those numbers are here because there is 2 or sometimes even 3 times
> the same date folder (different photographer uploaded files on the
> same day).

> I don't need it, but this will create conflict in the final result
> (folders with same name). No?

OK, based on that, one last question :). I assume you want to keep the photos in those otherwise-identical folders separated, right? That is, you're not willing/desiring to merge the folders' contents together.

Assuming that's true, how would you expect a duplicate folder to be renamed? For instance, let's say you had:

20 sept. 09
20 sept_2. 09
20 sept_3. 09

Would you expect the renamed folders to be:

2009-09-20_1
2009-09-20_2
2009-09-20_3

Or some other manner? Also, do you have folders with _numbers on more than just one of month, day, or year? If so, how should we handle those? As you can tell, your query is quite complex, and we're trying to make sure we handle it correctly.

regards,
-rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 10:49:13 -0800 (PST)

Thanks a lot for your time,
Best
G

On 11 déc, 18:58, Rob Griffiths <[email-masked]> wrote:
> On Dec 11, 2011, at 7:55 AM, gregol wrote:
>
> > "20 sept_2. 09",
> > "26 juil_2. 09",
> > "18 août 09_2",
> > "12 sept_2. 09",
> > "3 sept_2. 09",
> > "16 nov_3. 09",
>
> Based on this list, one last question: Is it important that the _2, _3, etc. are retained? Or can we drop them? And if we retain them, do you want them in the same location as they are now?
>
> thanks;
> -rob.

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 11 Dec 2011 09:58:21 -0800

thanks;
-rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 08:28:23 -0800 (PST)

Those are in fact image folders and not files, so yes there is no
extensions.

G

On 11 déc, 17:03, Rob Griffiths <[email-masked]> wrote:
> > sorry copy-paste mistake, here is a more readable version:
>
> > "20 sept_2. 09",
> > "14 août 09",
>
> Just to be clear, that's the _entire_ filename? There's no extension, there's no added text before or after the date portion?
>
> regards,
> -rob.

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 11 Dec 2011 08:03:52 -0800

regards,
-rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 07:55:10 -0800 (PST)

"20 sept_2. 09",
"14 août 09",
"29 juil. 09",
"26 juil_2. 09",
"23 août 09",
"13 mai 09",
"18 août 09_2",
"12 sept_2. 09",
"3 sept_2. 09",
"8 mai 09",
"16 nov_3. 09",
"23 sept. 09",
"10 août 09"

On 11 déc, 16:51, gregol <[email-masked]> wrote:
> Here is a list of examples of the folder names:
>
> 20 sept_2. 0914 août 0929 juil. 0926 juil_2. 0923 août 0913 mai 0918
> août 09_212 sept_2. 093 sept_2. 098 mai 0916 nov_3. 0923 sept. 0910
> août 0920 août 09
>
> They are in french and as you can see the long months are cut and some
> have "_number" added to them.
>
> And yes you are right, in fact my actual folders are named like this
> "2011-01-19"
> best
> G
>
> On 11 déc, 16:28, Rob Griffiths <[email-masked]> wrote:
>
>
>
>
>
>
>
> > On Dec 11, 2011, at 3:17 AM, gregol wrote:
>
> > > Thanks for your fast answer.
>
> > One more question before the answer...can you give me a few actual filename examples? I assume there's more to it than simply the date? We'd need to see exactly what the name looks like before and after. Also, we _strongly_ recommend not using slashes in filenames (as they're special characters in OS X for representing the path to a file). Would you be OK with a solution that made the filenames 2004-04-12 instead?
>
> > regards,
> > -rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 07:51:25 -0800 (PST)

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 11 Dec 2011 07:28:29 -0800

regards,
-rob.

---

From: gregol <[email-masked]>
Date: Sun, 11 Dec 2011 03:17:52 -0800 (PST)

On 11 déc, 05:13, Rob Griffiths <[email-masked]> wrote:
> On Dec 10, 2011, at 6:08 PM, gregol wrote:
>
> > I have a lot of old picture folders (from 2001 to 2006) that were
> > stamped by date like this: "12 March 2004".
> > But I want to have it changed to "2004/04/12"
>
> > Is it possible? Is a script available? If not, does somebody knows how
> > to write it for this action?
>
> It's possible, but I'll have to ask Peter (our founder and programmer) for his assistance. The easy bit is rearranging the parts; that can be done with a relatively straightforward regular expression. The complicated part is converting alpha month names to month numbers, and that's where I need Peter's assistance.
>
> I'll post something back when I have an answer.
>
> -rob.

---

From: Rob Griffiths <[email-masked]>
Date: Sat, 10 Dec 2011 20:13:48 -0800

-rob.

---

From: gregol <[email-masked]>
Date: Sat, 10 Dec 2011 18:08:05 -0800 (PST)

Hello,

Best
G