Custom Exif:DateTimeOriginal through scripting

Advanced Renamer forum
#1 : 07/10-16 20:43
Ephraim Hirschfeld
Ephraim Hirschfeld
Posts: 1
I want to have a custom file name format of "YYYY-MM-DD Day hhmmss" with the original DateTimeOriginal so I wrote the following script:

Pre batch script:
`
var orig,n,w = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
`
Script:
`
if (item.exifToolValue("DateTimeOriginal")){
orig = item.exifToolValue("DateTimeOriginal");
} else {
orig = item.exifToolValue("FileModifyDate")
//orig = item.exifToolValue("CreateDate")
}
var s = orig.split(/\D/);
var d = new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);
n="";
n += s[0]+"-"+s[1]+"-"+s[2]+" ";
n += w[d.getDay()]+" "; //get weekday
n += s[3]+s[4]+s[5];
return n;
`
the problem is that it comes up the Error of "Access violation at address 5D88F7B5 in module 'js32.dll'"
or it says in the error section "invalid script line 0 _itemFunction is not defined"

sometimes it does work, but most of the time it doesn't, is something wrong with my script?
even if I try somthing siple like
`
return item.exifToolValue("FileType");
`
it still makes problems.


07/10-16 20:43 - edited 07/10-16 20:44
#2 : 07/10-16 21:41
G. Lambany
G. Lambany
Posts: 187
Reply to #1:

Not been able to reproduce your problem. Maybe send me a few files that you know cause the problem with that code?

glambany@gmail.com

I've tried jpegs with exif data and empty files (no exif) and it doesn't crashes spider monkey with your code

as far as I can tell, even if it's not pretty, your code works...

cheers


07/10-16 21:41