Show Hidden files

Discussion in 'Mac Programming' started by covertsurfer, May 14, 2008.

  1. covertsurfer macrumors 6502a

    Joined:
    Jan 18, 2007
    #1
    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
    Code:
    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
     
  2. Blarged macrumors newbie

    Joined:
    Apr 14, 2008
    #2
    if you're using the command line, you can just use the -a flag on ls

    Code:
    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/)

    Code:
    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
     
  3. covertsurfer thread starter macrumors 6502a

    Joined:
    Jan 18, 2007
    #3
    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
     
  4. Blarged macrumors newbie

    Joined:
    Apr 14, 2008
    #4
    When you Save As, Under the File Format drop down, select application.
     

Share This Page