Last active
December 3, 2020 15:29
-
-
Save kaziridwan/2a7907b7c499191bc3678c291ad06392 to your computer and use it in GitHub Desktop.
Apple scripts for productivity
This file contains 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
on zero_pad(value, string_length) | |
set string_zeroes to "" | |
set digits_to_pad to string_length - (length of (value as string)) | |
if digits_to_pad > 0 then | |
repeat digits_to_pad times | |
set string_zeroes to string_zeroes & "0" as string | |
end repeat | |
end if | |
set padded_value to string_zeroes & value as string | |
return padded_value | |
end zero_pad | |
on run {input, parameters} | |
set d to (current date) | |
set yy to text -4 through -1 of (year of d as text) | |
set mm to text -2 through -1 of ("0" & (month of d as integer)) | |
set dd to text -2 through -1 of ("0" & (day of d)) | |
set hh to zero_pad(hours of d as integer, 2) | |
set mm to zero_pad(minutes of d as integer, 2) | |
set ss to zero_pad(seconds of d as integer, 2) | |
set datestring to yy & mm & dd & "-" & hh & mm & ss & "-" | |
tell application "System Events" | |
keystroke datestring | |
end tell | |
return datestring | |
end run |
also, follow this thread to whitelist the script as well as the apps that uses the script
Updated the script with inspiration from Glutexo's gist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typethedate.workflow
is inspired by this post