I’m a Mac user who, as of recently, switched from using a WINDOWS computer, and I confess that I miss the way in which you could right-click > new folder while saving. (I’m constantly deciding to make new folders on the spot; in short, I stay organized ONLY by being organized, NOT by employing the cute compensatory techniques of the spotlight, ⌘F, and Smart Folders, provided for you by the OS.
Recently I stumbled upon this blog post (http://soylentfoo.jnewland.com/articles/2007/11/22/spaces-application-assignments-and-applescript); one of the scripts the poster includes is one that opens a box that asks you to type in the number of which space (referring to leopard’s spaces) you want the front window to be assigned to.
It got me thinking, what if I could make a script that could (and this is the holy grail for me):
¢ pop-up a text box that asked you what you wanted to call the new folder: you would NOT have to specify where you want the folder to be located, as that would be set to the current location of the save-dialogue-box (if that’s what it’s called). Then, I would have a keyboard-shortcut in place to activate the script.
Of course, if the keyboard shortcut were not available, it would be somewhat to my satisfaction, which is better than not at all to my satisfaction. Likewise with obvious other less-nice potential alternatives.
Credit goes to Jesse Newland and here’s the aforementioned script:
set app_identifier to bundle identifier of (info for (path to frontmost application))
set app_identifier to do shell script "echo " & quoted form of app_identifier & " | /usr/bin/perl -pe 'use encoding utf8; s/(\\w)/\\L$1/gi'"
set displayString to "Assign " & app_identifier & " to Space:"
set defaultAnswer to 0
repeat
set response to display dialog displayString default answer defaultAnswer
try
set theNumber to (text returned of response) as number
exit repeat
on error errstr
set displayString to errstr & return & "Please try again."
set defaultAnswer to text returned of response
end try
end repeat
set app_construct to (run script "{|" & app_identifier & "|: " & theNumber & "}")
tell application "System Events"
tell spaces preferences of expose preferences
set app_layout to application bindings
end tell
end tell
set app_identifier to bundle identifier of (info for (path to frontmost application))
try
app_layout as number -- causes an error anyway
on error errstr
set app_locations to {}
set {TID, text item delimiters} to {text item delimiters, "{"}
set errstr to text item 2 of errstr
set text item delimiters to "}"
set errstr to text item 1 of errstr
set text item delimiters to ", "
set errstr to text items of errstr
set text item delimiters to TID
repeat with i in errstr
set o to offset of "|:" in i
tell i
set app_location to {}
set end of app_location to text 2 thru (o - 1)
set end of app_location to text (o + 2) thru -1
set end of app_locations to app_location
end tell
end repeat
end try
set spaces_bindings to {}
repeat with i from 1 to count app_locations
if app_identifier = item 1 of (item i of app_locations) then
--skip it
else
set spaces_bindings to spaces_bindings & (run script "{|" & item 1 of (item i of app_locations) & "|: " & item 2 of (item i of app_locations) & "}")
end if
end repeat
tell application "System Events"
tell expose preferences
tell spaces preferences
set application bindings to spaces_bindings
set spaces_bindings to app_construct & spaces_bindings
set application bindings to spaces_bindings
end tell
end tell
end tell