Created
November 16, 2012 16:10
-
-
Save JordanReiter/4088570 to your computer and use it in GitHub Desktop.
AppleScript file -- create scratch file in TextWrangler
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
property file_formats : {¬ | |
"cfm", ¬ | |
"html", ¬ | |
"js", ¬ | |
"py", ¬ | |
"sh", ¬ | |
"txt"} | |
property scratch_folder : "Macintosh HD:path:to:scratch:folder:" as alias | |
set gg to {year, month, day, hours, minutes, seconds} of (current date) | |
set yyyy to (item 1 of gg) as string | |
set mm to item 2 of gg as number | |
set dd to item 3 of gg | |
set hh to item 4 of gg | |
set nn to item 5 of gg | |
set ss to item 6 of gg | |
if mm < 10 then | |
mm = "0" & (mm as string) | |
end if | |
if dd < 10 then | |
dd = "0" & (dd as string) | |
end if | |
set datefolder to (yyyy as string) & (mm as string) & (dd as string) | |
tell application "Finder" | |
try | |
make new folder at scratch_folder with properties {name:datefolder} | |
end try | |
set today_folder to ((scratch_folder & datefolder) as string) as alias | |
end tell | |
tell application "TextWrangler" | |
activate | |
make new text document | |
set filetype to choose from list file_formats with prompt "File type" default items "py" | |
set filename to "scratch_" & (hh as string) & (nn as string) & (ss as string) & "." & filetype | |
save text document 1 to file ((today_folder & filename) as string) without saving as stationery | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use TextWrangler as my scratch app -- for diffing documents, doing search & replace, or writing up code to paste into a shell. However, at the end of the day I was having dozens of open windows that I had to sift through. Now, this script lets me create a scratch file saved into a scratch directory, so when I'm done I can just choose "Save all" and then "Close All" to close up my scratch files.