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

flashuni

macrumors newbie
Original poster
Jun 7, 2008
11
0
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

macrumors regular
Jul 23, 2002
106
3
OR
Give this a try.

Code:
ls -d /path/to/your/parent/dir | sed 's/^/"/;s/$/"/' | xargs -I {} -n1 zip -r {}.zip {}

-numero
 

flashuni

macrumors newbie
Original poster
Jun 7, 2008
11
0
Thanks

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
 

numero

macrumors regular
Jul 23, 2002
106
3
OR
To fix the problem with your fonts dir being zipped do this

Code:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.