Removing .DS_Store files from archives
The marvelous Shaun T. Erickson tipped me off on a sweet way to remove .DS_Store files from your folders before you archive them. Those are the "invisible" files added by Finder on your Mac. He writes that it doesn't matter whether you zip or tar: if they are in the directory tree, they get picked up by the archive. He suggests running the following command from terminal, substituting the appropriate directory for "your_dir":
find your_dir -type f -name .DS_Store -print0 | xargs -0 rm
After, just tar or zip up your tree.
Share
Source: http://blog.psmxy.org/
The marvelous Shaun T. Erickson tipped me off on a sweet way to remove .DS_Store files from your folders before you archive them. Those are...
Add a Comment
#19, it has nothing to do with rm limit. It is the shell character limit that causes the problem. when you do a glob (*) and your directory has a lot of files you overrun the shell limit. By the way if this is only required when you want to archive something why not do
gtar --execlude ".DS_Store" zcvf filename.tar.gz dir
Yeah, CleanArchiver rulez!
October 29 2007 at 6:30 PM Report abuse Permalink rate up rate down Reply- find has a '-delete' action which is the right thing to do
- piping to xargs works even for files with spaces in names if you use 'find -print0' and 'xargs -0', that's what these options are for.
Or, if you're using the fantastic Z-Shell:
rm **/.DS_Store
Just do:
sudo rm -rf *
That should take care of everything :)
NOTE: DO NOT ACTUALLY DO THIS
Don't know whether this is the case on the UNIX on which Mac OS is based, but some older UNIXes have versions of rm which has a limited number of arguments. It's a high limit, but I've bumped up against it a number of times when doing a 'rm *' in directories with huge number of files. Returns 'too many args' and would probably do so with a huge xargs.
Hence we had to do the find . -name * -exec rm -f {} ; quite a lot to get around that. I could see .DS_Store's getting numerous and hitting that limit, if there is with Darwin.
@Christopher Finke:
That will fail when your subdirectories have spaces in their names, which is why you should use -exec.
#14. No thanks. I rather not look at your spammy "excelent" (sic) website filled with spelling, factual, and grammar errors.
October 29 2007 at 4:27 PM Report abuse Permalink rate up rate down ReplyIf it is just a single folder, I find simply opening the folder, selecting all the files (which wont select the .ds since it is hidden) and selecting "create archive from xx items" is alot quicker.
October 29 2007 at 4:18 PM Report abuse Permalink rate up rate down ReplyWhy do I care about these files?
October 29 2007 at 4:14 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Wicked Jaw Breaker Noise-Isolating In-Ear Headphones for $6 + free shipping
- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



24 Comments