[SOLVED] Timestamp name to Human date name : Error 124 (Script invalid)

Advanced Renamer forum
#1 : 15/03-18 22:16
Mickaël L.
Mickaël L.
Posts: 3
Hi,

I have some files that have a timestamp date name ('1352235825804.jpg' for example) and I want to rename it into a human readable date name ('20121106_220345.jpg').
Here is my script :

var a = new Date(item.newBasename*1);
var year = a.getFullYear();
var month = (a.getMonth()+1) < 10 ? '0' + (a.getMonth()+1) : a.getMonth()+1;
var date = a.getDate() < 10 ? '0' + a.getDate() : a.getDate();
var hour = a.getHours() < 10 ? '0' + a.getHours() : a.getHours();
var min = a.getMinutes() < 10 ? '0' + a.getMinutes() : a.getMinutes();
var sec = a.getSeconds() < 10 ? '0' + a.getSeconds() : a.getSeconds();
var time = year + '' + month + '' + date + '_' + hour + '' + min + '' + sec ;
return time;

When I click on the "Applicate the script" button, the script runs successfully, and the new name appears on the tasks list. But when I click on the "Rename" button to confirm the action, for each file, I have an Error 124 (Script invalid).

Can someone help me ?
Thanks in advance ! :)
Micka


15/03-18 22:16 - edited 16/03-18 07:50
#2 : 16/03-18 00:45
Mark
Mark
Posts: 114
Reply to #1:
I can't help with scripting ...

But maybe AR's normal methods can do want you want ....

What is the source for your Date/Time values? In the example you gave, there seems no link between 1352235825804.jpg and 20121106_220345.jpg

Or are you saying you have something like 20121106220345.jpg that you want to look like 20121106_220345.jpg?

Mark


16/03-18 00:45
#3 : 16/03-18 07:36
Mickaël L.
Mickaël L.
Posts: 3
Reply to #2:
Thanks for your response !
In fact, the timestamp is a programming value that represents the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
So 1352235825804 milliseconds since this date, is the 2012/11/06 at 22:03:45 :)

Micka


16/03-18 07:36
#4 : 16/03-18 07:41
Mark
Mark
Posts: 114
Reply to #3:
Ah!

Sounds like some form of script would be necessary ….

Or use an external application (Excel) to create a list of corrected names, which you can then import into AR and use …..

Check out https://www.advancedrenamer.com/user_guide/metho d_list

Mark


16/03-18 07:41 - edited 16/03-18 07:43
#5 : 16/03-18 07:50
Mickaël L.
Mickaël L.
Posts: 3
Reply to #4:
No need ! It works ! Making this by script is more efficient :)
Here is my error : I had an undesirable character in the "Script testing..." button ! I just erase it, apply, and the script now runs perfectly ! :)
Thanks Mark for your fast responses !

Micka


16/03-18 07:50