#1 : 30/06-20 00:18 Phil March
Posts: 1
|
Hi
I'm experimenting with using the tool to rename photos that have very varied filenames to commonise them and sort by date. I've had to write a script to do this so that EXIF dates are used in the new filename where present, and file modified used otherwise. I've got it working and run it successfully on folders with over 2000 images, but I was occasionally getting errors such as "Access violation at address 7A41F7B5 in module 'js32.dll', Read of address 08EDEEFFC". Sometimes, if I restarted the program and ran again, it worked. Sometimes, I had to ensure the script was disabled when adding the folder to the list then enable the script and it would work. However, I've now come across a folder that only contains 179 jpegs that the tool persistently fails with. I've tried updating Java but it hasn't helped. The only thing that worked with this folder is to add files to the list in small batches of ~30 images, which is quite time consuming. Any idea what the cause is? This persistent problem is only with images from 2010 and before. Is this a tool problem or something I've introduced with my script? The script won't be best coding practice, but is functional (see below). I'd really like to make this work well and support the development so I can continue using this tool as the potential is great (it's so flexible). Best regards Phil var origname = item.newBasename; var crdate = item.exifToolValue('CreateDate'); // Extract EXIF date created (taken) if present var moddate = item.modifiedDate; // Extract File modified date as backup if there is no EXIF date taken //item.imgDate //item.newModifiedDate //item.videoExists //item.videoDate var lgth = moddate.length; var datetime = "undefined "; var datelabel = "undefined"; var yr = '2050'; var mth = '12'; var dy = '25'; var hr = '12'; var min = '00'; var sec = '00'; var date = '2050-12-25'; var time = '12h00m00'; var datetime = '2050-12-25 12h00m00 '; var datepresent = 0; var separatorpresent = 0; var chartoremove = 0; if (crdate.length === 0) // EXIF create date not present { datelabel = "mod date "; yr = moddate.getFullYear(); mth = moddate.getMonth() + 1; // Add 1 as month format is 0-11 for Jan to Dec if (mth<= 9){mth = "0" + mth;} // Convert month to 2 digit format dy = moddate.getDate(); if (dy<=9){dy = "0" + dy;} // Convert date to 2 digit format hr = moddate.getHours(); if (hr <=9){hr = "0" + hr;} // Convert hour to 2 digit format min = moddate.getMinutes(); if (min <=9){min = "0" + min;} // Convert minutes to 2 digit format sec = moddate.getSeconds(); if (sec <=9){sec = "0" + sec;} // Convert seconds to 2 digit format date = yr + '-' + mth + '-' + dy; time = hr + 'h' + min + 'm' + sec; datetime = date + ' ' + time + ' '; } else if (moddate.length !=0) // File modified date is present { datelabel = "cre date " yr = crdate.charAt(0) + crdate.charAt(1) + crdate.charAt(2) + crdate.charAt(3); mth = crdate.charAt(5) + crdate.charAt(6); dy = crdate.charAt(8) + crdate.charAt(9); hr = crdate.charAt(11) + crdate.charAt(12); min = crdate.charAt(14) + crdate.charAt(15); sec = crdate.charAt(17) + crdate.charAt(18); date = yr + '-' + mth + '-' + dy; time = hr + 'h' + min + 'm' + sec; datetime = date + ' ' + time + ' '; } else { datetime = '2050-12-25 12h00m00 '; } // Remove date pre-fix from original filename if present if (origname.length >=3) { if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2011') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2012') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2013') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2014') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2015') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2016') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2017') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2018') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2019') {datepresent = 1;} else if ((origname.charAt(0) + origname.charAt(1) + origname.charAt(2) + origname.charAt(3)) === '2020') {datepresent = 1;} else {datepresent = 0; } } // If a date is present, check if there are separators e.g. 2016-18-06 if (datepresent === 1) { if (origname.charAt(4) === '-') {separatorpresent = 1;} else if (origname.charAt(4) === '_') {separatorpresent = 1;} else if (origname.charAt(4) === ' ') {separatorpresent = 1;} else {separatorpresent = 0; } } //If a date is present with separators, remove 10 characters if ((datepresent === 1) && separatorpresent === 1 && origname.length >= 11) {chartoremove = 11; origname = origname.slice(11); } // If a date is present without separators, remove 8 characters if ((datepresent === 1) && separatorpresent === 0 && origname.length >= 9) {chartoremove = 9; origname = origname.slice(9); } return datetime + origname; |