PDA

View Full Version : Show Hidden files




covertsurfer
May 14, 2008, 03:27 PM
I am a recent switcher and am still getting my head around this UNIX malarkey and need some help.

I am doing some web development and I want to modify my .htaccess file which is hidden by default. I have a script to show hidden files defaults write com.apple.finder AppleShowAllFiles TRUE

I was wondering if I could save that as an Applescript or something and just double click the file so it would run that. In Windows I would run a *.bat file that would run the code inside it. Is there a OS X alternative?

Thanks



Blarged
May 14, 2008, 03:35 PM
if you're using the command line, you can just use the -a flag on ls

ls -a

to display all files regardless hidden or not.

However... I think you are more after this (per http://macenterprise.org/content/view/331/140/)


try
set myvar to do shell script "defaults read com.apple.finder AppleShowAllFiles"
if myvar is "FALSE" then
do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
do shell script "killall Finder"
else if myvar is equal to "TRUE" then
do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
do shell script "killall Finder"
else
display dialog "Error"
end if
on error
display dialog "Would you like to hide files or show files?" buttons {"Show", "Hide"} default button "Hide"
set myChoice to button returned of result
if myChoice is "Show" then
do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
do shell script "killall Finder"
else if myChoice is "Hide" then
do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
do shell script "killall Finder"
else
display dialog "Error"
end if
end try

covertsurfer
May 14, 2008, 04:04 PM
Do I save that as an *.scpt file?

I have found some example ones but when I click on them they just open the Script Editor?

Thanks

Blarged
May 14, 2008, 04:50 PM
Do I save that as an *.scpt file?

I have found some example ones but when I click on them they just open the Script Editor?

Thanks

When you Save As, Under the File Format drop down, select application.