1

tldr;

I want to run a script over an external hard drive and tar.gz every folder that ends with .app into their own archive. That is, I don't want them all in one tar.gz file, I want to create one for each folder.

I can generate a list of folders to be worked on via:

find /Volumes/External1 *.app -prune -print

I would now like to compress each of these into their own archive.

A second part to this is that I would then like to copy all those files, and every other file on the drive, including the archive, but not the folders they relate to, and copy them all to another location.

more info

I have created a linux raid box to act as a file server for my network. I mostly have Apple and Linux devices, although the occasional windows box does connect.

The issue I've been having is that OSX .app files are actually a folder, and it has a convoluted underlying structure.

I have been collecting all the drives in my network and backing them up to the file server. I generally run an MD5 hash over them on the OSX box, and then in linux I'll use MD5DEEP to confirm the hashes.

The actual problem is that directory counts and file sizes almost never align when dealing with .app folders. Everything else is matching up beautifully, except when it get's to one of these folders.

What I'm trying to do now in an effort to simplify everything is create a tar.gz file of each .app folder, and leave them in their present location (ie co-located with the .app folder) and I am going to store the tar file instead of the .app folder. This way it's a single file, easy to hash, copy, re-hash.

I have finally worked down to a list of files I want to work with that I can generate with:

find /Volumes/External1 -name *.app -prune -print 

two final steps

1. create the archive

This is my first sticking point: I don't want to create a single archive of all of these folders. I want one archive for each folder. So expanding from the generated list, how do I push the list into individually created archives?

2. moving everything from the drive

The drive is formatted in Mac OSX (Journaled) format, so I will be moving these files over a gigabit network and not actually plugging the external drive into the linux box (I am aware there is a way/hack to turn journaling off, do the copy, and turn it back on, but I am unaware of the implications of doing so, and as a result, I'd prefer not to do that. I'm happy to let it run overnight).

When I generate the copy command (I could do it from a terminal on either end), I would basically want to match up a command line that copies:

  • files and folders on the drive of any type except
  • folders have names ending in ".app"
  • not a file or folder located within such a folder
  • and to be sure to include the archive

To that end I have come up with:

find /Volumes/External1/ | grep -v '.app/'

which I can work with directly or send it to a file and work with that list. I suppose a file list is better, because it provides me with some level of "these are what I worked on"

my thinking

  • generate a file list of all .app folders (list 1)

    find /Volumes/External1/ -name *.app -prune -print > files.apps.list

  • run a script that compresses each folder in list 1 to an archive (leaving the original folder in tact)

    your assistance thanks

  • generate a second file list excluding .app folders (list 2)

    find /Volumes/External1/ | grep -v '.app/' > files.noapps.list

  • run a script over list 2 that moves each file across the network

    your help again, thanks

I'm thinking that both of these steps extend the find list that I can generate by -exec each step with tar and cp, but I'm now lost at how to put these together.

Thank in advance

1 Answer 1

0

Have find run the archiver.

find /Volumes/External1/ -name *.app -prune -exec script_to_archive_and_move {} \;

where script_to_archive_and_move is an executable that takes a .app name as an argument, archives it, then moves the archive file to its final destination. With this approach, you don't need the second find command at all.

1
  • but wouldn't that ONLY copy the .app archives? I'd need the second iteration of find to deal with everything else, wouldn't I?
    – Madivad
    Nov 16, 2015 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .