Created
September 11, 2014 08:52
-
-
Save DivineDominion/fe1d4d39baf45477a496 to your computer and use it in GitHub Desktop.
AppleScript to rename notes in nvALT with the Zettel ID and a title of your choosing. Also inserts the information as a header into the note.
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 characters
-- Extend "current date" | |
script FormattedDate | |
property parent : current date | |
on twoDigitDisplay(aNumber) | |
set multiplier to 10 ^ 2 #howManyDigits | |
return "" & (text 2 thru 3 of ((multiplier + aNumber) as string)) | |
end twoDigitDisplay | |
end script | |
to current_date() | |
tell FormattedDate to get "" & ¬ | |
(it's year as text) & ¬ | |
(twoDigitDisplay(it's month as integer)) & ¬ | |
(twoDigitDisplay(it's day)) & ¬ | |
(twoDigitDisplay(it's hours as integer)) & ¬ | |
(twoDigitDisplay(it's minutes)) | |
end current_date | |
on run {input, parameters} | |
set theDate to current_date() | |
display dialog "Title" default answer "" | |
set theTitle to (text returned of result) | |
set theZettel to theDate & " " & theTitle | |
--- You can add a second line with "Tags: " in here, for example | |
set theHeader to "" & theZettel & " | |
" | |
tell application "nvALT" to activate | |
tell application "System Events" | |
--- Save the old clipboard | |
set currentClipboard to the clipboard | |
--- Paste the header | |
set the clipboard to theHeader | |
keystroke "v" using command down | |
delay 0.3 | |
--- Rename the file (Cmd-R) and paste in the title | |
keystroke "r" using command down | |
set the clipboard to theZettel | |
keystroke "v" using command down | |
delay 0.3 | |
--- Move back to the editing pane and restore the clipboard | |
keystroke tab | |
delay 1 | |
set the clipboard to currentClipboard | |
end tell | |
return theHeader | |
end run |
@amelchi And you get this output when you run the script above? Because the current_date
function actually composes a string of numbers manually. Yours looks like a system-formatted date.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry for a late question... dummy perhaps

when I get to nvalt I get the date this way
how to correct it to your date format?
TIA