Can I batch .tar or .gzip from the terminal? HELP!!

DmaxGuy

Registered
:confused:

I work at a prepress company and I need the capability to be able to batch .tar or .gzip files from the command line.

When we archive files on Retrospect for WinDoze [can't change to Mac for this unfortunately], fonts are never archived because Retrospect for WinDoze doesn't copy the Mac resources.

When I get ready to archive jobs on our server, they're dragged to a folder called "Jobs_ToBeArchived". Inside this folder are hundreds of job folders with names like "1234_AdidasAd" or "2345_JoeBoxer". Inside these job folders contain a hierarchy of folders containing various parts of the job. "01_Layout", "02_PlacedFiles", "03_Fonts", "04_EPS" and so on.

What I need is a command line script that will find every instance of "03_Fonts" inside of "Jobs_ToBeArchived"; compress it to a .tar or .gzip file; leave the compressed file it in the same directory as the source, and if possible discard the original folder after it's compressed.

Any help would be greatly appreciated!

TIA,
Bob
 
I don't think that tar will keep the resource forks either.

There is a modified version of tar that preserves hfs resource forks, you can find it here:
http://www.metaobject.com/Products.html
You might want to give that a try.

As for the script, here's a first shot at one, using hfstar:

cd Jobs_ToBeArchived
find . -name 03_Fonts -print0 | xargs -0 hfstar -uf foo.tar

which will find all the folders named 03_Fonts and make an hfstar archive out of them in the root level of Jobs_ToBeArchived. To recover them, just cd to Jobs_ToBeArchived again, and:
hfstar -xf foo.tar
 
Oh - I guess the -print0 an -0 stuff isn't necessary if the folders will always have really simple names. That just lets you check for folders that have spaces and other goofy stuff in their names.
 
[FTPMacintosh:admin/Desktop/Fonts Test] admin# find . -name 03_Fonts -print0 | xargs -0 hfstar -uf foo.tar
xargs: hfstar: Permission denied

Hmmm... I'm logged in as root...

Any ideas?

Thanks!
 
try:
sudo find . -name 03_Fonts -print0 | xargs -0 hfstar -uf foo.tar

enter your password when prompted.

Even though you are logged in as root (unless you have enabled the root user account in OS X) you will still need to use sudo for some things.
 
Hmm. What happens to the resource forks if you format your HD as UFS?

Or - if you copy files from an HFS+ to a UFS partition?
 
Could it be that hfstar just doesn't have the execute permission bit set? (Try 'chmod a+x /path/to/hfstar')

brianleahy - examining the contents of the tar archives hfstar makes, you can see that the resource fork is just saved as a separate file with a specific name. So, if you have a file 'file' with a resource fork, the tar archive will contain files called 'file' (the data fork) and '._file' (the resource fork).

I think I remember reading OS X does something similar with UFS volumes, or any where file systems where resource forks aren't available; maybe not exactly the same naming convention, but the same idea. Never tried it though...
 
Well, I ended up using stuffit. Version 8.0 has 'stuff' and 'unstuff' command-line tools. Here's the script a friend of mine came up with.

find ./ \( -type d -name "03_Fonts" -exec stuff -f sit5 {} \; \); find ./ \( -type d -name "03_Fonts" -exec rm -Rf {} \; \)

It finds every instance of '03_Fonts' in the subdirectories of the current directory, stuffs the folder and deletes the original. Works perfectly.
 
Back
Top