Oookay. Thought I was clear in my writing. Guess not. Good luck.
If that is all, then it is easily scriptable. Would it be preferable for the file to be given the original record date as the created date or as custom metadata?
Thank you for your kind offer. Here is my case:
I store all my projects in DT. Over time, there are a bunch of project related photos taken. They accumulate in the photos iCloud.
Every now and then, I export these photos to the DT group with the corresponding project. Then I purge them in the photos app, where I keep only my private photos.
So I have jpg files with names like the iPhone assigned it, e.g. IMG_7862.jpg.
What I need would the ability to sort and filter the jpg files after record time stamp.
If DT could access the EXIF data would be fine. But there is a workaround:
So a good workaround would be a script which I could apply on jpg files to extract the record time stamp and to store it in the creation time date of the file.
Then, I could sort and filter like I can do with e.g. text files and would be a happy camper.
Another work around would be a script which renames the jpg file name to represent the record time stamp, e.g. 2022-08-19-21-56-02 (just the time I typing this message).
@cgrunenberg (and @chrillek actually, but my JXA capabilities are insufficient to be able to quickly whip up a finished script) has already done most of the work; I‘ll see if I can add to it and provide you a working script. Do you use the export function in Photos, or do you drag and drop to DT?
It seems my statement “dumping my life into DT” is missunderstood. I talk about relevant information about project data, correspondence, procurement, financial data, tax data, etc. and also photos which related to projects and activities kept in DT.
I learnt and appreciate that DT can hold all bit and pieces of a project in one place, no matter what file format it is.
I don’t know what your use case with DT is, but I assume that you probably have also photos in your database.
I would prefer the file system creation date (I am not sure it this the correct name used in English - I use the german language version and Devonthink inspector names it with “Erstellt”
Creation date is properly shown in inspector, can be used for sorting and filtering. That is perfect.
With custom metadata, I have no experience if sorting and filtering works.
Maybe I’m comming in late, if I haven’ overlooked, about how many photos you are tallking about?
My foto library is about 2.5 TB (more than 200 k photos) and located on a dedicated hard drive. There is really good DAM software for photographers on the market, e.g. Photo Supreme, Photo Mechanic, iMatch… A very good freeware is XnView MP. All these have great capabilities and can read, display and modify exif data, filter photos by exif values, keyword management, color management and much more.
I love DT3, but I will never try managing my photo with it (I use photo supreme).
Probably it helps to take a look in this direction.
Edit: ups - I didn’t get that you use Apple Photos. Unfortunately these programm do not work with Apple Photos
Very few, and I don’t care about their creation date as reflected in DT.
The following script needs to be triggered by a smart rule; I suggest experimenting first, so setting up a smart rule which only applies to a small number of test files. The smart rule action needs to be Execute Script - External - Get EXIF Image Date and make Created Date.
The script needs first to be unpacked and saved to /Users/yourusername/Library/Application Scripts/com.devon-technologies.think3/Smart Rules.
This is the script verbatim:
on performSmartRule(theRecords) tell application id "DNtp" try repeat with this_item in theRecords if the type of this_item is equal to picture then try set this_image to the image of this_item tell application "Image Events" set this_file to open file this_image set this_date to value of metadata tag "creation" of this_file close this_file end tell end try set this_year to characters 1 thru 4 of this_date as string set this_month to characters 6 thru 7 of this_date as string set this_day to characters 9 thru 10 of this_date as string set this_time to characters 12 thru -1 of this_date as string set creationDate to my convertDate(this_day, this_month, this_year, this_time) set creation date of this_item to creationDate end if end repeat on error error_message number error_number if the error_number is not -128 then display alert "DEVONthink" message error_message as warning end try end tell end performSmartRule on convertDate(image_day, image_month, image_year, image_time) set imageDate to image_day & "." & image_month & "." & image_year & " " & image_time return date imageDate end convertDate
Once you are happy with what the script does, you can adapt your smart rule - you could, for example, set the rule to run the script whenever you import an image. For images already in your database, you could set up a temporary smart rule which applies to all image files in all databases.
Be warned: changes made by scripts cannot be undone. You must test the script before running it on a production database. I choose to backup my databases before running any script which applies to large sections of the database.
In my tests, the script changed the created date of the item to the image date. It is not impossible that different language versions of both iOS and macOS may use different date formats. If you are shown an error message, please quote it here verbatim.
The first time you run the smart rule / script macOS will ask you whether you wish to allow DEVONthink to automate Image Events; you need to agree to this.
Whilst I had mentioned it further up, full disclosure: the script is not all my work; I pieced it together from the script provided by @cgrunenberg and things I picked up from others along the way. An aside: the date returned by Image Events is in the format “YYYY:MM:DD HH:MM:SS”, which is not recognised by the
A clarification: EXIFTool isn’t used with Open With. It’s a shell command that is called under-the-hood.
tonight I finally found time to test the script.
I am impressed twice, at first for your kind assistance to provide a great solution and to walk me through the implementation and secondly, how well the solution works.
Gosh, since I am often adding photos to projects managed in DT, this is a real time saver.
Once you come to Munich, I will be happy to pay you a beer or a coffee
I am realising that for my workflow, it would be great to apply this function to one or several selected (highlighted) images instead of using a smart rule.
Ideally, by assigning a hotkey to this function.
So, I am kindly asking for more help, for a modification, if feasible.
TIA – BR Herb
EDIT: chrillek was so kind to guide me already. Mission completed - Thank you all
You could remove the first and last line of the script posted by @Blanc. Than, add
set theRecords to selected records
right after the line
tell application id "DNtp"
and save this script in DT’s script folder. This version will run on all selected records.
Cool, edit done and it does the trick.
Thank you very much.
And even cooler, assigning a hotkey worked as well.