Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exif-renamer uses the wrong time for ctime fallback on Mac #10

Closed
bbugh opened this issue Nov 23, 2017 · 4 comments
Closed

exif-renamer uses the wrong time for ctime fallback on Mac #10

bbugh opened this issue Nov 23, 2017 · 4 comments

Comments

@bbugh
Copy link

bbugh commented Nov 23, 2017

I have some files that don't have exif data but have the correct Mac created time. However, exif-renamer is using the wrong stat value (at least for Mac) to get the created time.

Using Mac's built-in GetFileInfo command, you can see here that the created time is as expect (05/04):

GetFileInfo IMG_2708.JPG
file: "IMG_2708.JPG"
...
created: 05/04/2017 14:55:07   # correct, expected time
modified: 05/04/2017 14:55:07

However, the stat in lib/exif-renamer.js:173 results in this:

# util.inspect(src.stat);
Ctime is Stats {
  ...,
  atimeMs: 1511456562000,
  mtimeMs: 1493927707000,
  ctimeMs: 1511454878000,
  birthtimeMs: 1493927707000,
  atime: 2017-11-23T17:02:42.000Z,
  mtime: 2017-05-04T19:55:07.000Z,
  ctime: 2017-11-23T16:34:38.000Z,          # not correct
  birthtime: 2017-05-04T19:55:07.000Z }     # correct, expected time

The ctime here is what Mac uses as "Date Added" which was created by cp -p, which preserves ctime (which Mac stores in birthtime).

Here's what it looks like in Finder:

image

I was able to fix this by changing it to use birthtime as the fallback instead of ctime. I know Mac stores different times and such, but I don't know the implications of this on other platforms.

173,174c173,174
<             else if (this.config.fallback_ctime === true && src.stat && src.stat.ctime) {
<                 datetime = src.stat.ctime;
---
>             else if (this.config.fallback_ctime === true && src.stat && src.stat.birthtime) {
>                 datetime = src.stat.birthtime;
@dylansmith
Copy link
Owner

Hey @bbugh, thanks for the thorough description of the issue. I'll look into it when I get a spare moment.

@dylansmith
Copy link
Owner

@bbugh can you checkout this branch and see if this fixes your issue?

@bbugh
Copy link
Author

bbugh commented Nov 28, 2017

This works perfectly! Thank you so much for fixing this.

@dylansmith
Copy link
Owner

Great, I'll bump the version and release it

@dylansmith dylansmith mentioned this issue Jan 15, 2018
dylansmith added a commit that referenced this issue Jan 15, 2018
* fixed #9 by adding sequential filename generation for conflicting filepaths; reduced test/demo images

* #9: added support for globs in rename_dir and --glob flag

* improve detection of file creation time (#10)

* fix file creation calc, add better test

* updated deps, removed Grunt for tooling

* remove grunt dep, updated exif-parser

* updated README

* updated README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants