1

How can I make some conditional actions only if a file doesn't exist?

I found the requirement check "If file exists" but not "If file doesn't exist".

Perhaps using an apple script in the pre-install check?

Thanks in advance for your help

sdespont
  • 13,915
  • 9
  • 56
  • 97

1 Answers1

1

Here's an example...

set someFile to (path to desktop as text) & "sample.txt"

tell application "Finder"
    if not (exists file someFile) then
        -- do something here
    end if
end tell
regulus6633
  • 18,848
  • 5
  • 41
  • 49
  • Thanks for your answer. Your script works perfectly in AppleScript Editor, but when I try to include my test in the postInstall action, the installer return an installation error. Shall I return something like "return true" or something like that to specify that my script execution has been successfully done? – sdespont Apr 30 '12 at 07:59
  • 1
    Hello, after few research on the web, the "applescript" files can be called from pre-install and post-install script using the shell command "osascript your_applescript_file.scpt". – sdespont Apr 30 '12 at 10:32