Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript help with true or false script

I'm in need of a applescript that will run two different scripts based on the outcome of an existing file.


I have a folder called Status. Inside this folder is a simple text file called Good.rtf


I would like a script that would run one or the other script base on the true or false output. If file exists then:


true will

run script A


false will

run script B


I have been searching the web for two days looking for something to help me get started on this and have not had much success.

Please help me. I really would appropriate any help or guidance.


Thanks....

Ron

iMac, Mac OS X (10.7.3)

Posted on Apr 2, 2015 2:56 AM

Reply
7 replies

Apr 2, 2015 9:06 AM in response to Ron60

Ron


AppleScript calls this kind of script a "Conditional" = if this > then that


Some templates are in MacintoshHD/Library/Scripts/Script Editor Scripts/Conditionals

User uploaded file


You don't need a value for "false" in binary as it is merely "not true" (else)

----

if true then

-- insert if actions here

else

-- insert else actions here

end if

----


If you already have your Scripts A & B working, copy>pastethem into the "insert actions here" part as appropriate


ÇÇÇ

Apr 5, 2015 11:47 PM in response to Ron60

Hello


If I understand it correctly, you may try something like this.



set f to "/path/to/Status/Good.rtf" try f as POSIX file as alias set e to true on error set e to false end try if e then run script a --run script ("/path/to/a.scpt") as POSIX file else run script b --run script ("/path/to/b.scpt") as POSIX file end if script a return 1 end script script b return 0 end script




Regards,

H

Applescript help with true or false script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.