Reply
   
 Using POSIX path in Applescript 
 
 
  #1 (permalink)  
Old 14-03-2007, 10:19 PM
Member

Group: Regulars


Using POSIX path in Applescript

Hi guys,

What I'm trying to do is pass a posix path directly to Applescript instead of the normal path like MyMac:this folder:that file. etc.

I found an example in a Apple document about Applescript and changed it to this:

Code:
set this_path to "Users/username/Desktop/tuborg/tuborg_logo.jpg"
set the new_path to POSIX file this_path


tell application "Preview"
    
    activate
    open file new_path
    
end tell
That works but is there a better way to do it and if the POSIX Path has a space escaped like:
Code:
set this_path to "Users/username/Desktop/tuborg/tuborg2\ logo.jpg"
it doesn't work....any ideas?

Many thanks,

Kuzey
Kuzey is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #2 (permalink)  
Old 15-03-2007, 12:06 AM
Regular

Group: Regulars
Location: Toongabbie, NSW


Put a slash in front (/Users/...)?

Explanation: Unix paths are relative to the current working directory unless they start with a slash.

Cheers
Steffen.
dotnet is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #3 (permalink)  
Old 15-03-2007, 11:25 PM
Member

Group: Regulars


Ooooh that was easy....many thanks Steffen

Now , the funny thing is if the space is escaped it won't work:

Code:
set this_path to "/Users/username/Desktop/tuborg/tuborg2\ logo.jpg"
but if the space is unescaped it works:

Code:
set this_path to "/Users/username/Desktop/tuborg/tuborg2 logo.jpg"
Could there be a small difference between a POSIX path and a shellpath (when you drop a file on the terminal window), I thought they were both the same?

All the best,

Kuzey
Kuzey is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #4 (permalink)  
Old 16-03-2007, 01:30 AM
Regular

Group: Regulars
Location: New Hampshire, USA


Quote:
Originally Posted by Kuzey View Post
Could there be a small difference between a POSIX path and a shellpath (when you drop a file on the terminal window), I thought they were both the same?
You don't need to escape the embedded space if it's inside double quotes.
__________________
24" 2.4GHz iMac, 2GHz MBP, (1.66GHz, 250GB mini + Dell 2405FPW + Belkin F1PI241EGau), 16GB 1stG 'Touch
chrism238 is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #5 (permalink)  
Old 16-03-2007, 03:02 AM
Regular

Group: Forum Leaders
Location: Sydney


Quote:
Originally Posted by chrism238 View Post
You don't need to escape the embedded space if it's inside double quotes.

Absolutely true
__________________
MacBook 2.4Ghz C2D Superdrive w/ 4Gb ram, 160Gb HDD (White)
iMac 20" 2.16Ghz C2D w/ 3Gb ram, 256Mb video ram (White)
iPhone 3G 8Gb
1Tb Time Capsule
purana is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #6 (permalink)  
Old 16-03-2007, 10:09 PM
Member

Group: Regulars


I knew about the double quotes in regards to shell commands but it's the applescript and shellpath that's getting me confused.

So, is there another way to set this_path to a posix path without using the quotes or do I need to manually change the "\ " to a " " first and then go from there?

Thanks guys,

Kuzey
Kuzey is offline
Profile CardPM
Go to the top of the page
Reply With Quote
 
Reply

Thread Tools

 
Similar Threads
 
Thread Thread Starter Forum Replies Last Post
Leopard 'welcome' movie path. gallet Mac OS X & All Software 6 08-01-2008 08:19 PM
Desktop path rickyd Help and New Mac User Support 9 23-05-2007 08:40 PM
POSIX error: Cannot allocate memory Zoe Help and New Mac User Support 4 06-04-2007 09:50 PM
The path of me Nevets_Anderson Terminal, UNIX, Command line & X11 1 07-05-2006 09:37 AM
iWork 06 = no upgrade path from 05? marc Mac OS X & All Software 4 28-03-2006 12:09 PM