macOS X - How to use the Terminal to copy data, but exclude certain folders

Tony101

Suspended / Banned
Messages
391
Edit My Images
No
Hello,

I need to copy a load of files from one external drive to another, but I'd like to exclude certain nested folders which have specific filename attributes.

To do this via drag & drop within the Finder would be extremely inefficient as I would be copying terabytes of redundant data which will be immediately deleted (ie. copy a bunch of folders, wait an hour or so for the process to complete successfully, then 'Find' all the folders where the name contains "???" and delete them - repeat with another bunch of folders...until completed).

I think this would be a fairly simple, and vastly more efficient, task carried out via the Terminal, but I have virtually no knowledge of using command lines or scripting etc. (or the pros & cons between "cp", "rsync", "ditto" etc.).

In an ideal world I'd read all the 'man' pages and learn the necessary commands, but this is a one time operation and it would ultimately be quicker to just use the Finder...hence why I'm asking the awesome denizens of TalkPhotography.

Many thanks in advance.


A little more detail...

The folders are organised along the lines of:
(It makes sense to me, but may not be obvious to others) :-)

YYYY
YYYYMMDD
YYYYMMDD Edits
YYYYMMDD Exports
YYYYMMDD Exports (Press)
YYYYMMDD RAW
www
www press​
YYYYMMDD
YYYYMMDD Edits
YYYYMMDD Exports
YYYYMMDD Exports (Subject)
YYYYMMDD RAW
www
www (Subject)​
YYYYMMDD+DD+DD
YYYYMMDD Edits
YYYYMMDD RAW
YYYYMMDD+DD+DD Exports
YYYYMMDD Edits
YYYYMMDD RAW
YYYYMMDD Edits
YYYYMMDD RAW
www (updated)​
Etc.
Etc.
Etc.

I want to copy all the folders excluding those which have a filename that contains "RAW" and "www".

Thanks for reading this far and for any information, instructions, advice you can provide.

Cheers!
Tony
 
You could probably use find or rsync for this.
rsync is probably easiest using the --exclude parameter.

The man page and countless on-line examples should help illustrate how to use rsync.
 
Sorry for not replying sooner.

Yes, rsync works brilliantly - many thanks.

I'm a CLI neophyte so the 'man' page quickly starts melting my tiny brain. Also all the on-line articles I read seem to offer their own 'recipe' with little explanation of their choices, so it's been hard to ascertain the practical advantages/disadvantages of differing commands.

It's been an interesting, educational and frustrating experience but ultimately I've achieved my goal and gained a barely rudimentary grasp on one tiny area of using the CLI.

Thanks again.

Cheers!
 
Apologies for not being more explicit but I'm busy to say the least at the moment.
One of the big benefits of the CLI is that it's ultimately more flexible than GUI tools. Learning to grapple with it should pay dividends in future.
 
Back
Top