Re: POSIX paths query
Re: POSIX paths query
- Subject: Re: POSIX paths query
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 08 Oct 2003 09:25:30 -0700
On 10/8/03 8:23 AM, "Steve Thompson" <email@hidden> wrote:
>
 I have this script:
>
 
>
 set temp to "Server:Master Database:to be Databased:AUGUST IMAGE
>
 UPLOADS - No17:layouts:161999-Image.eps"
>
 set test to quoted form of POSIX path of (temp)
>
 tell application "Finder"
>
 exists file temp
>
 exists file test
>
 end tell
>
 
>
 And the output is
>
 
>
 tell application "Finder"
>
 exists file "Server:Master Database:to be Databased:AUGUST IMAGE
>
 UPLOADS - No17:layouts:161999-Image.eps"
>
 --> true
>
 exists file "'/Volumes/Server/Master Database/to be Databased/AUGUST
>
 IMAGE UPLOADS - No17/layouts/161999-Image.eps'"
>
 --> false
>
 end tell
>
 
>
 So it exists in HFS format but not in POSIX format. Can anyone explain
>
 to me why that is and how to stop it? I need to check if the file
>
 exists on this server (mounted as an NFS volume) before I ditto a file
>
 on to it, purely to save time (don't want to copy a file if it's
>
 already there as it's over an slow DSL line).
    set temp to "Server:Master Database:to be Databased:AUGUST IMAGE UPLOADS
- No17:layouts:161999-Image.eps"
    set test to POSIX path of (temp)
    tell application "Finder"
        exists file temp
        --> true
        exists file (POSIX file test as Unicode text)
        --> true
    end tell
Or you could do it this way:
    set temp to "Server:Master Database:to be Databased:AUGUST IMAGE UPLOADS
- No17:layouts:161999-Image.eps"
    set test to POSIX path of (temp)
    try
        get alias temp
        set bool to true
    on error
        set bool to false
    end try
    --> true
    try
        get (POSIX file test) as alias
        set bool to true
    on error
        set bool to false
    end try
    --> true
So:
1) Don't use 'quoted form': that's just for 'do shell script'.
2) The Finder's 'file' object is different from AppleScript's 'file' (not to
mention that the 'file' produced by 'POSIX file' may be something else
again.)
3) The Finder can coerce AppleScript (colon-delimited) file paths into its
hierarchial  file objects (file "a" of folder "b" of folder "c" of disk "d")
by sticking 'file' in  front of the file path: but first you need a
colon-delimited path to give it.
4) 'POSIX file' creates that odd 'file' thing, which creates an error, but
'POSIX file as Unicode text' will give the colon-delimted file path, which
the Finder can use.
5) Or you can just test for the existence of 'alias file:path' without
involving the Finder if you prefer.
 
-- 
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: 
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.