Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Put the quoted form of POSIX paths into Script Editor Apps
As a beginner learning the basics of do shell script in AppleScript, I'm finding that most of my file and folder names have spaces in them. As such, I have two choices when writing paths: either escape all the spaces as I type them, or use the AppleScript quoted form of POSIX path construct.

Both methods still require significant typing and exact spelling, and I'm from the generation that didn't learn to type. To ease my discomfort, I wrote this script for use in Script Menu:
tell application "Finder"
  set Itms to selection
  set als to Itms's item 1 as alias
  set aPath to quoted form of POSIX path of als
end tell

tell application "Script Editor"
  activate
  tell front document
    set contents of selection to aPath
  end tell
end tell
The script takes the currently-selected file or folder in Finder, and puts its quoted form of POSIX path into Script Editor's front document at the insertion point (or replaces the selection if text is selected). If you type as fast a my 12 year old granddaughter, you probably don't need this.
    •    
  • Currently 2.20 / 5
  You rated: 1 / 5 (5 votes cast)
 
[11,578 views]  

Put the quoted form of POSIX paths into Script Editor | 6 comments | Create New Account
Click here to return to the 'Put the quoted form of POSIX paths into Script Editor' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Put the quoted form of POSIX paths into Script Editor
Authored by: qwerty denzel on Aug 29, '08 05:11:36PM

You may be interested to learn that (in 10.5 at least) you can simply drag a file into a Script Editor document to add its POSIX path.
Then you can use <b>quoted form of</b> or simply type the single quotes yourself inside the string.



[ Reply to This | # ]
Put the quoted form of POSIX paths into Script Editor
Authored by: StrawHousePig on Aug 29, '08 05:40:32PM

Here's the script I run from the Finder's AppleScript folder (/Users/[StrawHousePig]/Library/Scripts/Applications/Finder/).

tell application "Finder" to set the clipboard to POSIX path of (selection as text)



[ Reply to This | # ]
Just curious....
Authored by: germ on Aug 29, '08 07:00:26PM

what do you do with the time that you save by typing Itms instead of Items, als instead of alias, etc.?



[ Reply to This | # ]
Just curious....
Authored by: marksch on Aug 30, '08 09:14:45AM

He needs the time to figure out the meaning of the abbrevs ;-)

---
Economy-x-Talk
Have your own custom software created
http://economy-x-talk.com



[ Reply to This | # ]
Just curious....
Authored by: musselrock on Aug 30, '08 12:15:51PM

To avoid using AppleScript keywords as variable names. No timesaving involved, but I can tell from the variable name what I'm referring to.



[ Reply to This | # ]
Put the quoted form of POSIX paths into Script Editor
Authored by: drc_007 on Aug 30, '08 02:54:33PM