Help with script

Advanced Renamer forum
#1 : 25/01-18 02:22
Andreas Toth
Andreas Toth
Posts: 5
What is wrong with the following script???

function(index, item) // No I don't include this line
{ // No I don't include this line
var date = item.exifToolValue('DateTimeOriginal');
var source;

if(date === null)
date = item.createdDate;
source = 'FILE';
source = 'EXIF';

var options = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
minute: '2-digit'
var prefix = new Intl.DateTimeFormat('en-US', options).format(date);

return prefix + '_' + source + '_' +;
} // No I don't include this line

By the way, I really don't want to have to specify a locale at all, but this the only way I know how.

P.S. I wish the software had better error feedback. Maybe there is but I haven't found it. All I know is that my script has an error. What the error is I don't know but I wish the software could tell me so that I didn't have to contact support or post to the forum to work out what's wrong. Would speed up things immensely as well.

25/01-18 02:22
#2 : 01/02-18 08:12
Brian Hanlon
Brian Hanlon
Posts: 29
Reply to #1:
I don't know just what scripting language you are using, but 'if(date === null)' looks awful suspect to me, I have a gut feeling that it should be 'if(date == null)' - just based on the few scripting languages which I use myself.
Hope it helps,

Must have been half asleep when I wrote that, it is JS isn't it? - What is the intended purpose of the script? If it is just to retrieve the EXIF Date/Time from the file, surely the existing AR options handle that quite adequately?

OK, after a sleep and a head-scratch, I still feel that the original 'if(date === null)' statement is where the problem lies. the === operator asks "equal value and equal type" and I don't think that you'll have the same type, even when the 'date' is returned as empty. - It is very likely that testing for '>= 0' may solve your problem.

If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?

01/02-18 08:12 - edited 01/02-18 21:44