Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Why does this simple apple script generate an error?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="zBernie" data-source="post: 1677328" data-attributes="member: 283713"><p>I named the script below ToggleShowHiddenFiles.scpt. When I run the script I get this error:</p><p></p><p><span style="color: #A52A2A">./ToggleShowHiddenFiles.scpt</span></p><p><span style="color: #A52A2A">./ToggleShowHiddenFiles.scpt:134:140: script error: Expected “then”, etc. but found identifier. (-2741)</span></p><p></p><p>The syntax appears correct, can anyone tell me how to avoid this error?</p><p></p><p></p><p></p><p><span style="color: #A52A2A">#!/usr/bin/osascript</span></p><p><span style="color: #A52A2A"></span></p><p><span style="color: #A52A2A"></span></p><p><span style="color: #A52A2A">tell current application</span></p><p><span style="color: #A52A2A"> set HiddenStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"</span></p><p><span style="color: #A52A2A"> if Hidden Status = "NO" then</span></p><p><span style="color: #A52A2A"> do shell script "defaults write com.apple.finder AppleShowAllFiles YES && killall Finder"</span></p><p><span style="color: #A52A2A"> else</span></p><p><span style="color: #A52A2A"> do shell script "defaults write com.apple.finder AppleShowAllFiles NO && killall Finder"</span></p><p><span style="color: #A52A2A"></span></p><p><span style="color: #A52A2A"> end if</span></p><p><span style="color: #A52A2A">end tell</span></p></blockquote><p></p>
[QUOTE="zBernie, post: 1677328, member: 283713"] I named the script below ToggleShowHiddenFiles.scpt. When I run the script I get this error: [COLOR="#A52A2A"]./ToggleShowHiddenFiles.scpt ./ToggleShowHiddenFiles.scpt:134:140: script error: Expected “then”, etc. but found identifier. (-2741)[/COLOR] The syntax appears correct, can anyone tell me how to avoid this error? [COLOR="#A52A2A"]#!/usr/bin/osascript tell current application set HiddenStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles" if Hidden Status = "NO" then do shell script "defaults write com.apple.finder AppleShowAllFiles YES && killall Finder" else do shell script "defaults write com.apple.finder AppleShowAllFiles NO && killall Finder" end if end tell[/COLOR] [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Why does this simple apple script generate an error?
Top