In the lines below I try to create locations and then correct their creation and modification dates:
tell application id "DNtp"
set newGroup to create location "Firefox_Export/toolbar/[P] ReOrg Writing, Notes, Infos"
set creation date of newGroup to "Sunday, 19. April 2020 at 10:53:25"
set modification date of newGroup to "Thursday, 23. April 2020 at 10:47:03"
set newGroup to create location "Firefox_Export/toolbar/[P] Automate Ulysses App"
set creation date of newGroup to "Monday, 20. April 2020 at 07:29:10"
set modification date of newGroup to "Monday, 20. April 2020 at 17:10:34"
end tell
But it works for all other records, except locations.
This here for example works:
set urlName to "Bibliography management with bibtex - Overleaf, Online LaTeX Editor"
set urlURL to "https://www.overleaf.com/learn/latex/bibliography_management_with_bibtex"
set datCreated to "Saturday, 25. April 2020 at 22:08:42"
set datUpdated to "Saturday, 25. April 2020 at 22:08:42"
create record with {name:urlName, URL:urlURL, type:bookmark, creation date:datCreated, modification date:datUpdated} in newGroup
I can even create a fresh group and change its creation and modification dates:
tell application id "DNtp"
create record with {name:"Test group", type:group, creation date:"Saturday, 25. April 2020 at 22:04:29"} in incoming group
end tell
It’s only when I create a group via create location modifying this groups creation / modification dates fail.
So the question is: Does create location not return a group record? Or a record at all?
Try to coerce a date string by this method first - just a suggestion
Set theDate to date "2020.04.25.22.08.42" -- just a numeric string of ur example "Saturday, 25. April 2020 at 22:08:42"
-- use theDate to do whatever you want
This does not work inside a DEVONthink tell block, a handler is needed
tell application id "DNtp"
set sel to selection of window 1
set theRecord to item 1 of sel
set C to creation date of theRecord as string
set theDate to my makeDate(C)
end tell
on makeDate(dateString)
set theDate to date dateString
end makeDate
Thank you @ngan for the suggestion. Tried that already based upon the help from @pete31, but I get a syntax error whenever I use date "(some date string)"
The error message is: Expected end of line, etc. but found “"”.
I suppose the problem is in create location. It does not return a proper group reference, so acting on what it returns does not change the dates.
tell application id "DNtp"
(* PROCESS FOLDER: /toolbar/[R] Bibliography - BibTex *)
set newGroup to create location "Firefox_Export/toolbar/[R] Bibliography - BibTex"
set creation date of newGroup to my makeDate("Saturday, 25. April 2020 at 22:04:29")
set modification date of newGroup to my makeDate("Saturday, 25. April 2020 at 23:23:58")
end tell
on makeDate(dateString)
set theDate to date dateString
end makeDate
The create record with AppleScript command of DEVONthink receives the input basically unfiltered/unparsed, therefore DEVONthink can apply conversions like string to date on its own. But setting a property like the creation date directly requires a valid date object due to AppleScript’s preprocessing.