Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to create a sym link to a network directory when i log in. This is working for a couple of other directories without spaces in the name, but for the life of me I cannot get this one director to work and I'm assuming it has to do with the space characters.

in a terminal window I can successfully create the link manually with

ln -s "/Volumes/D/Contracts and Price Sheets"/ ~/Desktop/Contracts

my current applescript looks like this

tell application "Finder"
  mount volume "smb://user:password@192.168.0.0/D"
  set contractsPath to "/Volumes/D/Contracts and Price Sheets/"
  if not (exists ((path to desktop as text) & "hDrive")) then
    do shell script "ln -s /Volumes/D/Home/user/ ~/Desktop/hDrive"
  end if
  if not (exists ((path to desktop as text) & "sDrive")) then
    do shell script "ln -s /Volumes/D/Data/ ~/Desktop/sDrive"
  end if
  if not (exists ((path to desktop as text) & "Inventory")) then
    do shell script "ln -s /Volumes/D/Inventory/ ~/Desktop/Inventory"
  end if
  if not (exists ((path to desktop as text) & "Contracts")) then
    do shell script "ln -s " & quoted form of the POSIX path of contractsPath & " ~/Desktop/Contracts"
  end if
end tell

I'm sure all these conditionals are bad habit, but I'm not an experienced programmer. Anyway, the first three drives mount successfully, however the final directory (with spaces in the title) just will not work. I've combed the web for answers, but keep getting no results.

Any and all input is greatly appreciated. Thanks!

share|improve this question
    
Have you tried adding escaped quotation marks to the contractsPath string, i.e. "\"/Volumes/D/Contracts and Price Sheets/\""? –  Dan J Jan 11 '13 at 20:17
    
yes, I've also tried escaping the backslash with another backslash.. so /Volumes/D/Contracts\\ and\\ Price\\ Sheets/ –  user1191167 Jan 11 '13 at 21:18

2 Answers 2

Hm, I've run a similar script in AppleScript Editor but it works ok for me:

set contractsPath to "/Users/subhu/Test test test/"
do shell script "ln -s " & quoted form of the POSIX path of contractsPath & " ~/Desktop/test"

Note that, if you escaping a backslash with another backslash you have to use just contractsPath, not quoted form of the POSIX path of contractsPath, e.g.:

set contractsPath to "/Users/subhu/Test\\ test\\ test"
do shell script "ln -s " & contractsPath & " ~/Desktop/test"

Try it.

share|improve this answer

contractsPath is already a posix path. Try:

do shell script "ln -s " & quoted form of contractsPath & " ~/Desktop/Contracts"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.