Reputation: 9035
I've never created a script before and am looking for a tutorial on writing a script for OSX 10.6. There is a terminal command that can show all hidden files. It's
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Changing TRUE to FALSE will hide system files. I want to make a script that checks the value of AppleShowAllFiles, and if TRUE, writes FALSE, and if FALSE, writes TRUE.
Is this done in TextEdit and saved as a .sh file? Can a script be something I double-click that just runs, or do I have to start terminal and type a command to execute the script? I'm a newb, sorry
Thanks guys
Upvotes: 5
Views: 6467
Reputation: 28703
make a file switchhideshow.command with the following content:
#!/bin/sh
show=`defaults read com.apple.Finder AppleShowAllFiles 2>/dev/null`
if [ "$show" == "TRUE" ]; then
defaults write com.apple.Finder AppleShowAllFiles FALSE
else # here we come, if it is FALSE or is empty (the default)
defaults write com.apple.Finder AppleShowAllFiles TRUE
fi
killall Finder
then: chmod a+x switchhideshow.command
Ready. Unfortunately, you should close the terminal every time you run it. Also, you might want to look at this. It describes how to call the shell script to show hidden files from Automator Actions.
Upvotes: 3
Reputation: 19071
You can use the .command
extension to turn it into something you can click on. Just be sure to save it as text-only (Format -> Make Plain Text in TextEdit).
Upvotes: 6