Replacing Date

Advanced Renamer forum
#1 : 14/03-14 08:59
Shawn
Shawn
Posts: 16
Hi,

For a file/folder, is there an easy way to replace a date with a xx numeric value without having to have 12 different renaming methods?

January would be 01
February would be 02
and so on...

Thanks!


14/03-14 08:59
#2 : 14/03-14 12:43
Stefan
Stefan
Posts: 264
Reply to #1:

Depends on your real file names, I guess.

I would have suggested to try Replace Method
(http://www.advancedrenamer.com/user_guide/metho d_replace)

" If you want to replace more than one phrase, you can separate the different phrases with \ "

Find: "01 \02 \03 \04 "
Replace: "Jan \Feb \March \April "


But this doesn't seams to work with ARen 3.52 and 3.62?
Or I don't know how to use? Or it is not meant for such multi phrase replacement?
I always get the back slash presented in the New Filename column too.
So this feature is only to find different pattern and replace all with always the same string.

Perhaps Kim want to add a new rule:
If Occurrences==Multi, then
replace each find-pattern with the replace-pattern at the very same position from left?
(I though that works already like this ;-) )


- - -

But ok, a script to the rescue:

(http://www.advancedrenamer.com/user_guide/metho d_script)

[code]
newname = item.name;

newname = newname.replace(/ 01 /g, ' Jan ');
newname = newname.replace(/ 02 /g, ' Feb ');
newname = newname.replace(/ 03 /g, ' March ');
//and so on...

return newname;
[/code]

NOTE: shown spaces are mandatory to match the right digits. But depends on your real file names.


- - - EDIT

Oh, you want it the other way around?:


[code]
newname = item.name;

newname = newname.replace(/ January /g, ' 01 ');
newname = newname.replace(/ Feb /g, ' 02 ');
newname = newname.replace(/ Mar /g, ' 03 ');
//and so on...

return newname;
[/code]


.

----------
If this tool had saved you time, perhaps you want to donate an Dollar to Kim?
See http://www.advancedrenamer.com/download >>> [Donate] button.


14/03-14 12:43 - edited 14/03-14 12:46
#3 : 17/03-14 08:42
Shawn
Shawn
Posts: 16
Reply to #2:

Where did I go wrong here?

return item.newBasename;
newname = item.name;

newname = newname.replace(/ January /g, ' 01 ');
newname = newname.replace(/ February /g, ' 02 ');
newname = newname.replace(/ March /g, ' 03 ');


17/03-14 08:42
#4 : 17/03-14 08:42
Shawn
Shawn
Posts: 16
Code is not working.


17/03-14 08:42