Renaming files - how to find correct date?
Version 4.19
I'm renaming 10000+ files. It works but slow, but that okey.
Tried turning off Win11 antivirus for that folder its scanning. Seems to help.
I found the software nice, so purchased it.
I'm using the software to rename photos, so all files goes from this:
IMG_5578.JPG
to
IMG_5578 - 2010-12-14 - 18-40-16 - 2272x1704.JPG
My setup is that i find files and us this:
<Name> - <Img DateOriginal:yyyy-mm-dd> - <Img TimeCreate:hh-nn-ss> - <Width>x<Height>
Problem (and abit difficult to explain, but trying):
Is that I have timestamp in files from <Date taken>, <Date Modified> and <Date Created>.
In older photos these dates are not correct and I have to manually set it...
Some photos have Date Modified as the correct date and is missing Date taken.
Other photos have Date created and is missing Date taken and Date modified is also wrong.
Example:
Lets say I know the photos are taken in 2001. And it should select the date within the 2001.
Some times modified and date taken is wrong is 2014, but date created in 2001)
Would be nice if I could select priority
1. Date taken
then look for
2. Date created
then look for
3. Date Modified
BUT is should always look for year 2001 (or month etc)..
I'm renaming 10000+ files. It works but slow, but that okey.
Tried turning off Win11 antivirus for that folder its scanning. Seems to help.
I found the software nice, so purchased it.
I'm using the software to rename photos, so all files goes from this:
IMG_5578.JPG
to
IMG_5578 - 2010-12-14 - 18-40-16 - 2272x1704.JPG
My setup is that i find files and us this:
<Name> - <Img DateOriginal:yyyy-mm-dd> - <Img TimeCreate:hh-nn-ss> - <Width>x<Height>
Problem (and abit difficult to explain, but trying):
Is that I have timestamp in files from <Date taken>, <Date Modified> and <Date Created>.
In older photos these dates are not correct and I have to manually set it...
Some photos have Date Modified as the correct date and is missing Date taken.
Other photos have Date created and is missing Date taken and Date modified is also wrong.
Example:
Lets say I know the photos are taken in 2001. And it should select the date within the 2001.
Some times modified and date taken is wrong is 2014, but date created in 2001)
Would be nice if I could select priority
1. Date taken
then look for
2. Date created
then look for
3. Date Modified
BUT is should always look for year 2001 (or month etc)..
Reply to #1:
You can do this with careful use of "{if}" conditions and multiple add methods.
But I think it's more straightforward to just use JavaScript.
Create a new "Script" method and then paste the following code into it:
//----------------------------------
function convertExifStrToDate (exifDateStr) {
/*--- Raw Exif returns dates like "2025:11:16 19:37:31".
Convert to "2025-11-16T19:37:31" for Date(), then return a Date object.
*/
if (exifDateStr) {
let dParts = exifDateStr.split (" ");
dParts[0] = dParts[0].replace (/:/g, "-");
let dateStr = dParts.join ("T");
return new Date (dateStr);
}
else return null;
}
DateTakenStr = item.metadata("DateTaken");
DateTaken = convertExifStrToDate (DateTakenStr);
if (DateTaken) {
goodDate = DateTaken;
}
else {
goodDate = new Date (item.createdDate); // Use actual file created date. Usually as good as Exif values.
// Also, every file will have a created date, not dependent on Exif data. So no need to use modified date.
}
goodDateStr = app.formatDate (goodDate, "yyyy-mm-dd - hh-nn-ss");
//console.log ("goodDateStr: ", goodDateStr);
return item.newBasename + " - " + goodDateStr;
//----------------------------------
Be sure to click "Apply script".
Then add an "Add" method to append the <Width>x<Height>.
Note that the above method doesn't need to fall back to modified date because it uses the file's created date -- which will always be present.
But it's a trivial matter to use all Exif dates (if present). That is if you trust (any) Exif values more than file values.
You can do this with careful use of "{if}" conditions and multiple add methods.
But I think it's more straightforward to just use JavaScript.
Create a new "Script" method and then paste the following code into it:
//----------------------------------
function convertExifStrToDate (exifDateStr) {
/*--- Raw Exif returns dates like "2025:11:16 19:37:31".
Convert to "2025-11-16T19:37:31" for Date(), then return a Date object.
*/
if (exifDateStr) {
let dParts = exifDateStr.split (" ");
dParts[0] = dParts[0].replace (/:/g, "-");
let dateStr = dParts.join ("T");
return new Date (dateStr);
}
else return null;
}
DateTakenStr = item.metadata("DateTaken");
DateTaken = convertExifStrToDate (DateTakenStr);
if (DateTaken) {
goodDate = DateTaken;
}
else {
goodDate = new Date (item.createdDate); // Use actual file created date. Usually as good as Exif values.
// Also, every file will have a created date, not dependent on Exif data. So no need to use modified date.
}
goodDateStr = app.formatDate (goodDate, "yyyy-mm-dd - hh-nn-ss");
//console.log ("goodDateStr: ", goodDateStr);
return item.newBasename + " - " + goodDateStr;
//----------------------------------
Be sure to click "Apply script".
Then add an "Add" method to append the <Width>x<Height>.
Note that the above method doesn't need to fall back to modified date because it uses the file's created date -- which will always be present.
But it's a trivial matter to use all Exif dates (if present). That is if you trust (any) Exif values more than file values.
Reply to #2:
Hi guys,
Randy, I thought Stig said his timestamp dates were wrong (as mine often are). I don't know if this will help you, Stig, but if Randy's solution isn't working for you you might want to try this script:
const dateY = "2001" ;
n = item.newBasename ;
dt = app.parseTags( "<DateTaken>" ) ;
if ( !dt ) {
dt = item.metadata( "DateTimeOriginal").replace(/:/g, "-" ) ;
}
if ( !dt ) { dt = "" } ;
if ( dt.slice( 0,4 ) != dateY ) { return } ;
nn = n + " - " + dt +
app.parseTags( " - <ExifTool:ImageWidth><-:x><ExifTool:ImageHeight>") ;
nn = nn.replace(/([^\w]) - /g, "$1" ) ;
nn = nn.replace(/ - $/, "" ) ;
return nn;
(Sorry, missed a line when copying; fixed now)
Set "const dateY" to whatever year you want. I used exiftool values for the WxH because for some reason some of my metdata values were null; not sure why they didn't match up. This worked for me in limited testing.
Addendum: There's a thread from early last year that talks a lot about this type of thing, although not exactly this. Stig, if you want to investigate more it *might* (or might not) be helpful. In the first reply message I talk a little bit about a way to do something similar but with cascading non-script methods. Although looking back it doesn't seem very clear even to me. :) Anyway,
https://www.advancedrenamer.com/forum_thread?forum_id=14252
Best,
DF
Hi guys,
Randy, I thought Stig said his timestamp dates were wrong (as mine often are). I don't know if this will help you, Stig, but if Randy's solution isn't working for you you might want to try this script:
const dateY = "2001" ;
n = item.newBasename ;
dt = app.parseTags( "<DateTaken>" ) ;
if ( !dt ) {
dt = item.metadata( "DateTimeOriginal").replace(/:/g, "-" ) ;
}
if ( !dt ) { dt = "" } ;
if ( dt.slice( 0,4 ) != dateY ) { return } ;
nn = n + " - " + dt +
app.parseTags( " - <ExifTool:ImageWidth><-:x><ExifTool:ImageHeight>") ;
nn = nn.replace(/([^\w]) - /g, "$1" ) ;
nn = nn.replace(/ - $/, "" ) ;
return nn;
(Sorry, missed a line when copying; fixed now)
Set "const dateY" to whatever year you want. I used exiftool values for the WxH because for some reason some of my metdata values were null; not sure why they didn't match up. This worked for me in limited testing.
Addendum: There's a thread from early last year that talks a lot about this type of thing, although not exactly this. Stig, if you want to investigate more it *might* (or might not) be helpful. In the first reply message I talk a little bit about a way to do something similar but with cascading non-script methods. Although looking back it doesn't seem very clear even to me. :) Anyway,
https://www.advancedrenamer.com/forum_thread?forum_id=14252
Best,
DF