-
-
Save amien8/00aa8889ccecb56930fd to your computer and use it in GitHub Desktop.
Revisions
-
redoPop revised this gist
Jun 10, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,4 @@ At the time of writing, [Hazel's](http://www.noodlesoft.com/hazel.php) default d This script provides a custom date attribute reflecting the time the photo was actually taken. As written, it's intended to be added as an embedded script in a "Run JavaScript" rule action, so that it's custom attribute can be used in subsequent "Sort into subfolder" patterns. The date this script exposes is obtained via [`sips -g creation [filename]`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html). It's not clear to me exactly which EXIF attribute the sips "creation" property comes from, but it seems reasonable to assume it's either `DateTimeOriginal` or `DateTimeDigitized`. -
redoPop revised this gist
Jun 10, 2015 . No changes.There are no files selected for viewing
-
redoPop created this gist
Jun 10, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ At the time of writing, [Hazel's](http://www.noodlesoft.com/hazel.php) default date attributes all refer to an image file's creation date rather than the date on which the photo was originally taken. The two dates may differ. This script provides a custom date attribute reflecting the time the photo was actually taken. As written, it's intended to be added as an embedded script in a "Run JavaScript" rule action, so that it's custom attribute can be used in subsequent "Sort into subfolder" patterns. The date this script exposes is obtained via [`sips -g creation \[filename\]`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html). It's not clear to me exactly which EXIF attribute the sips "creation" property comes from, but it seems reasonable to assume it's either `DateTimeOriginal` or `DateTimeDigitized`. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ var app = Application.currentApplication(); app.includeStandardAdditions = true; var theDate = app.doShellScript( 'sips -g creation ' + // Dragons below: Q&D shell escape: ('' + theFile).replace(/ /g, '\\ ') ) // Parse SIPS output & extract date .match(/(\d{4}):(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})/) .slice(1) // Q&D numberification of stringy dates .map(function (i) { return +i }); // Offset the month by 1 because JavaScript theDate[1] -= 1; return { hazelOutputAttributes: [ // Apply array of values to Date constructor new (Function.prototype.bind.apply( Date, [null].concat(theDate) )) ] };