Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

covertsurfer

macrumors 6502a
Original poster
Jan 18, 2007
579
7
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
 

Blarged

macrumors newbie
Apr 14, 2008
24
0
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
 

covertsurfer

macrumors 6502a
Original poster
Jan 18, 2007
579
7
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.