Every now and then I have to get my hands dirty in the Terminal and delete hidden files. As its not something I have to do often I tend to forget the actual commands so this a reminder.
To view all hidden files:
defaults write com.apple.finder AppleShowAllFiles TRUEkillall Finder
To hide the files:
defaults write com.apple.finder AppleShowAllFiles FALSEkillall Finder
To delete the .svn files:
Navigate to the folder. The easiest is to type “cd” and then to drop the folder into the Terminal window.
find ./ -name ".svn" | xargs rm -Rf
10 ResponsesLeave a comment ?
Hey Niqui, tip for you to make it much easier each time you wanna toggle them on/off. This gives you a dock icon you can just click…
Open up Script Editor from Applications/AppleScript
Paste in the following…
tell application “Finder” to quit
display dialog “Show Hidden Files…” buttons {“YES”, “NO”} default button 2
copy the result as list to {buttonpressed}
try
if the buttonpressed is “YES” then do shell script “defaults write com.apple.finder AppleShowAllFiles OFF”
if the buttonpressed is “NO” then do shell script “defaults write com.apple.finder AppleShowAllFiles ON”
end try
tell application “Finder” to launch
Then choose File > Save As > and choose “Application”. Make sure to uncheck “start up screen” as that can be annoying.
Then you can run it from the new .app file it creates, right click in dock and choose “Keep in dock” and you’re away!
Sorry typo in the script… change the OFF to ON and the ON to OFF (buttons are wrong way around).
Hi Richard
Thanks for that – its very cool
I really should spend more time with AppleScript.
just in case someone doesn’t want to mess with terminal or applescript, (although, I think I’m gonna try it)…
I use the FireFTP add-on for FireFox. Under tools, click on options and check, “show hidden files”. You might find that you might have accidentally uploaded some .svn hidden files on your server. However it allows you to see the hidden files on your mac as well, and you can then delete them…
Your find/xargs pipe will work great until an ‘.svn’ directory is under a directory containing a space. For example:
# mkdir -p “a b/.svn”
Running your command will try to delete two entities called “./a” and “b/.svn”, and as you pass “-f” to “rm”, this will silently fail. To fix this use:
# find ./ -name “.svn” -print0 | xargs -0 rm -Rf
This instructs “find” to seperate the output using a null byte (which will never occur in a filename) and also instructs xargs to expect the input to be in that format.
great post will come in handy… now if everybody can be bothered to delete thier .ds_store using the same technique i might actually respect some of you mac users…
oh and btw… another option is on some svn clients they have an option to export a project which exports all the files into a directory without any of the .svn mess… i know subclipse has this feature…. Right Click on the directory ->Team->Export
Nice tips. I like the one for hidden files
Weird. I never see these “.ds_store” files. The Win users I work with keep complaining about them. I think they put them there just to have something to complain about the Mac with.
Seeing as this is always the link Google gives me when I search for this I thought I’d share this with you :
find . -name “*.svn” -exec rm -rf {} \;
Which seemed to work perfectly for me today
Seb