In Windows I would create a .bat file to run this script from my desktop, on my Mac how do I create something similar that can be run from the desktop to execute this:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
In Windows I would create a .bat file to run this script from my desktop, on my Mac how do I create something similar that can be run from the desktop to execute this:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Create a file with the following content
#!/bin/bash
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
From the terminal.app, run chmod o+x <filename>
to make the file executable.
To run the file simply open the terminal.app and ./<filename>
Shoan's instructions for making a shell script will work fine, but you need to run it from within Terminal. If you add jtbandes suggestion of giving the filename a .command
suffix (.sh
doesn't work for me) the file becomes double-clickable in the Finder -- but it still opens a Terminal window, and leaves it open when it finishes. If you don't want to be bothered with this, there are a couple of ways of doing the job without any extraneous UI stuff:
1- Create an AppleScript in the AppleScript Editor (which is either /Applications/Utilities/AppleScript Editor.app or /Applications/AppleScript/Script Editor.app, depending on which version of OS X you have). Enter this as your script:
do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder"
... and then save the script in Application format so it's double-clickable (if you save it as a "Script", double-clicking it will open the script editor instead).
2- Create an Automator workflow using /Applications/Automator. Use the Application template (again, to make it double-clickable), find the "Run Shell Script" action in the second column (it's a huge list, so I just type "shell" in the search field at the top) and drag it into the workflow space at the right. Make sure it's set to use a reasonable shell, paste in your commands, and save.