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

zimv20

macrumors 601
Original poster
Jul 18, 2002
4,402
11
toronto
first, let me describe the problem:

i want to back up all my .ptf (pro tools session) and .rtf (record and mix notes) files to .mac. Because my music folder (w/ all its many subfolders) contains big audio files, i can't just tell Backup to start at /music.

so what i thought i'd do is write a Bourne shell script to create a parallel directory structure, with only the .ptf and .rtf files, and Backup that. i need to preserve the directory structure, because not all the .rtf files have unique names. then i'd use cron to schedule the script to run once/day.

i've got the script all written, BUT the cp command doesn't behave as i remember it behaving "back in the day".

i had (mis)remembered that this command:

% cp -Rp /foo/bar/baz/foo.txt ./bak

... would create ./bak/foo/bar/baz. but unless i omit foo.txt from the command, it doesn't. did it used to work that way? who knows, but it's not doing that now.

SO...

i need to find a workaround. not all directories have .ptf and .rtf files in them, so i don't want to replicate irrelevant directories in the backup hierarchy. also, i create new directories every few days, so i don't want to have to remember to also create them in the backup hierarchy. i.e. the script should pick those up automagically.

here's the magic command i have so far, but the result is all the files are copied into a single directory, specified by $DESTDIR:
Code:
% find . \( -name "*.ptf" -or -name "*.rtf" \) \! -path "*/Session\ File\ Backups/*" -exec cp -Rp {} $DESTDIR \;
(note: i'm ignoring files in any subdir called "Session File Backups")

i've also tried stuff along the lines of:
Code:
% find . -name "*.ptf" -print | xargs -I '{}' cp -Rp {} $DESTDIR
... but of course that's not working either. sadly, even if the destination hierarchy exists, i've discovered, the -Rp option doesn't drop the files in the right spot. they go in $DESTDIR and that's that.

i'm thinking something along the lines of find's -prune to grab the directory, and appending that to $DESTDIR, but i can't quite get it sussed out.

i'm embarrassingly stumped. maybe i should write it in nawk. hmmm....

any ideas?
 

zimv20

macrumors 601
Original poster
Jul 18, 2002
4,402
11
toronto
hey, i like the *.[pr]tf bit, nice touch.

figures that as soon as i post a long, detailed question i'll figure something out on my own. i discovered the pax command, and it does what i need. the magic command is now:
Code:
% find . -name "*.[pr]tf" \! -path "*/Session\ File\ Backups/*" -exec pax -rw {} $DESTDIR \;

thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.