2

What's the correct syntax in the Applescript below to make this app run by double clicking on it rather than how it runs now by just running the Applescript in the AS script editor?

The Shell script is located at:

ToggleHidden.app/Contents/Resources/Scripts/toggle.sh

And it is set to execute by all. (I did chmod a+x toggle.sh)


Applescript

set bottomRoot to (path to me) as alias

 tell application "System Events"
 set myPath to (POSIX path of container of bottomRoot)

end tell

set scriptPath to quoted form of (myPath & "/toggle.sh")

do shell script scriptPath

Shell script

#!/bin/sh

STATUS=`defaults read com.apple.finder AppleShowAllFiles

if [ $STATUS == TRUE ];

then

defaults write com.apple.finder AppleShowAllFiles FALSE

else

defaults write com.apple.finder AppleShowAllFiles TRUE

fi

killall Finder

sleep .5

open .

2 Answers 2

1

You could also just use do shell script:

do shell script "killall Finder
[[ $(defaults read com.apple.finder AppleShowAllFiles) = 1 ]] && b=false || b=true
defaults write com.apple.finder AppleShowAllFiles -bool $b
sleep .5
open -a Finder"
1
  • Thank you for the help in solving this! Perhaps I was trying to over complicate things. I'm pretty new to Applescript and was trying to write out something elegant and useful. I did have to drag the second line to fall in place directly after the first line and also it's weird that it ran on my MacBook (10.8.5) but when I sent it do my girlfriends and brothers it wouldn't run (all 10.8.5). Any thoughts on that? And again thank you!
    – BsdHelper
    Commented Nov 22, 2013 at 18:31
2

Try:

set myPath to POSIX path of ((path to me as text) & "Contents:Resources:Scripts:toggle.sh")
1
  • Thank you adayzdone but it still wasn't working with the code line you posted. I've changed it up after several days of Googling and trial/error. Any other thoughts on my situation? Thanks again for your help.
    – BsdHelper
    Commented Nov 22, 2013 at 3:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .