View Full Version : Zip Command Help!
flashuni
Jun 8, 2008, 10:48 AM
I am trying to preserve the resource forks in font files while zipping them.
The font files are in folders, and I am trying to zip each folder up individually and not just into one big archive.
What is the zip parameter to do this?
numero
Jun 8, 2008, 12:26 PM
Give this a try.
ls -d /path/to/your/parent/dir | sed 's/^/"/;s/$/"/' | xargs -I {} -n1 zip -r {}.zip {}
-numero
flashuni
Jun 8, 2008, 12:51 PM
Thanks a bunch, but your script makes my fonts folder into one big archive.
Is their any way that I could do this piece of code to each folder inside on my fonts folder. When I ran it, it just created a large archive of my whole fonts folder and didn't just zip up each folder individually inside of the fonts folder.
Thanks, Flashuni
For Example Here is my previous script that doesnt work:
## zip the contents of each folder in the current directory into an archive:
for d in *; do if [ -d "$d" ]; then cd "$d"; cd ..; fi; done
## zip every folder in the current directory into an archive:
for d in *; do if [ -d "$d" ]; then zip -r -j "$d.zip" "$d"; fi; done
## example recursively forces the deletion of the directory if zip returns true:
for d in *; do
if [ ! -d "$d" ]; then
continue
fi
if ! zip -R -j "$d.zip" "$d"; then
continue
fi
motulist
Jun 8, 2008, 04:58 PM
I'd just use automator.
flashuni
Jun 8, 2008, 05:16 PM
I'd just use automator.
I have tried that, but if someone could point me in the right direction it would be a great help!
Thanks, Flashuni
numero
Jun 8, 2008, 06:04 PM
To fix the problem with your fonts dir being zipped do this
ls -d /path/to/your/parent/dir/* | sed 's/^/"/;s/$/"/' | xargs -I {} -n1 zip -r {}.zip {}
I added the "/*" to the parent dir path.
What you want fed into the sed command is the list of directories that will be zipped. Do just the "ls -d /path/to/parent/dir/*" command by hand and see if that gives you the folders that you want individually zipped.
Sorry about that little slip. You are just feeding something in that is one level too high. It should work with this change.
-numero
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.