PDA

View Full Version : Help with my applescript




Macsavvytech
Sep 2, 2010, 06:34 AM
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"
try
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



kainjow
Sep 2, 2010, 07:57 PM
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
else
-- file doesn't exist
end if
end tell

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

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.

Macsavvytech
Sep 3, 2010, 07:54 PM
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