dt returns date created not date modified for general files

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
longski96
Posts: 4
Joined: 24 Apr 2018, 03:21

dt returns date created not date modified for general files

Post by longski96 »

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.

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;

	}
Any way around this?!
longski96
Posts: 4
Joined: 24 Apr 2018, 03:21

Re: dt returns date created not date modified for general files

Post by longski96 »

spent about 2 hours on this and figured it out 5mins after posting this! doh!

I found this works:

Code: Select all

{new Date(file.lastModified()).dateTimeString}
Post Reply