Stateful Scripts in Automator?

Solution 1:

The following example works for me in a Run Shell Script action in Automator:

f="/Volumes/Canvio1TB/EyeTV Archive/sync.ffs_lock"

if [ -f "$f" ]; then
    echo "$f exists."
else
    echo "$f does not exist."
fi

Note: Shell is set to: /bin/bash

This also works:

f="/Volumes/Canvio1TB/EyeTV Archive/sync.ffs_lock"

[ -f "$f" ] && echo "$f exists." || echo "$f does not exist."

Here it is in AppleScript in a Run AppleScript action:

set f to "/Volumes/Canvio1TB/EyeTV Archive/sync.ffs_lock"

tell application "System Events"
    if exists file f then
        return f & " file exists." as string
    else
        return f & " file does not exist." as string
    end if
end tell