dt returns date created not date modified for general files
Posted: 24 Apr 2018, 03:29
I am trying to batch rename my photo collection.
Unfortunately, some photos have the exif stripped or missing.
In this case I wish to use date modified, however {dt} returns the OS date created which is when the files were last copied, not the OS date modified which is roughly equal to when the file was created by the camera on its file system.
I have check the code and this is the case, see " File Last-Modified for generic files" but then the code uses the Creation date.
Any way around this?!
Unfortunately, some photos have the exif stripped or missing.
In this case I wish to use date modified, however {dt} returns the OS date created which is when the files were last copied, not the OS date modified which is roughly equal to when the file was created by the camera on its file system.
I have check the code and this is the case, see " File Last-Modified for generic files" but then the code uses the Creation date.
Code: Select all
@Define("dt")
public ZonedDateTime getTimeStamp() {
File f = getMediaFile();
// try EXIF Date-Taken for image files or File Last-Modified for generic files
try {
return new ImageMetadata(f).getDateTaken().get();
} catch (Exception e) {
// ignore and default to file creation date
}
try {
return Instant.ofEpochMilli(getCreationDate(f)).atZone(ZoneOffset.systemDefault());
} catch (Exception e) {
debug.warning(e::toString);
}
return null;
}