Hi,
I’m trying to make a very simple template for journal entries.
I’d like to create a text file named YYYY-MM-DD.
I’ve found that I can use %month% and %days% in file names, but those variables don’t add the leading zero for month and days between 1 and 9.
I can’t use %shortDate% because I need the system wide short date set to the italian format.
This can be done by using a template script package (.templatescriptd):
Create a new script in Apple’s Script Editor
Paste this code:
tell application "DEVONthink Pro"
set theDate to current date
set theDay to (day of theDate) as integer
set theDayStr to (theDay as string)
if theDay < 10 then set theDayStr to "0" & theDayStr
set theMonth to (month of theDate) as integer
set theMonthStr to (theMonth as string)
if theMonth < 10 then set theMonthStr to "0" & theMonthStr
set theDateStr to ((year of theDate) as string) & "-" & theMonthStr & "-" & theDayStr
set theFile to (path to me as string) & "Contents:Resources:%theDate%.rtf"
import theFile placeholders {|%theDate%|:theDateStr} to current group
end tell
Save it as a script bundle (.scptd)
Add an RTF document named %theDate%.rtf to the script bundle (just drop it on the drawer in the Script Editor)
Save it again
Finally, change the script’s extension to .templatescriptd and move it to ~/Library/Application Support/DEVONthink Pro 2/Templates.noindex.
Hi,
I am trying to achieve the same thing, however I am stuck at step 4. How can I add the .rtf to the script bundle? I don’t see a drawer in the Applescript Editor and no menu entry that adds a file to the script either. Has the script editor changed in the last five years, so that I need to do this differently now?
Thank you, alastor, that’s what I thought the drawer was.
It turns out that it did not wort for me yesterday, since I manually renamed the file to the .scptd format instead of properly saving it into this format. This way the drawer was not greyed out, but I still could not move any files into it.
Yes, manually changing the extension would cause that.
Another thing to be aware of: when you save a script bundle somewhere else, or with a new name, any files you put into its Resources folder are not copied to the new bundle.
The Editor does not really know they are there.