Help with my applescript

Discussion in 'Mac Programming' started by Macsavvytech, Sep 2, 2010.

  1. macrumors 6502a


    May 25, 2010
    OK now what i want to do is create an apple script to check if file exists if it exists open it if not open a different file.
    This is what i have

    tell application "Finder"
    open "Location of File 1"
    on error
    open "Location of File 2"
    end try
    end tell

    The problem is apple script cant decide on error or not with an iTunes library file
  2. Moderator emeritus


    Jun 15, 2000
    You can check for a file's existence like so:
    tell application "Finder"
    	set f to POSIX file "/path/to/file"
    	if f exists then
    		-- file exists
    		-- file doesn't exist
    	end if
    end tell
    I'm not sure what you mean. Can you clarify? Are you trying to open an iTunes library file? If so, I'm not sure if iTunes would handle that directly.
  3. thread starter macrumors 6502a


    May 25, 2010
    You can directly open an iTunes library file through iTunes by double clicking it I have edited my script abit yesterday it now resembles yours mildyly I would show you but I'm away from my computer at the moment

Share This Page