i am trying to transfer a directory structure from a sd card to an external hard drive while preserving the integrity of the directory structure and sub folders and files within it.

i need to exclude files with the file extension .123 from being transferred over as those files need to be fixed.

once the remaining files with .123 extension are fixed i need to re-run a command to transfer even those files over while making sure that duplicates are not copied over and also making sure the balance of the files with the .123 extension are not transferred over until they are fixed.

is there a quick way to get this done without my doing it manually?

i have over 500 folders and countless sub folders and files to transfer.

  • hi thanks for responding. what is the meaning of source destination? – user232153 Jan 8 '14 at 18:27
  • source is the source directory from which you are copying, and destination is the destination directory to which you want to copy. Btw, please post further comments on the answer, instead of the question. When someone comments on my answer, I get an inbox message. I almost missed your comment. I saw it only because I was reviewing all my answers. – GabrielF Jan 8 '14 at 21:46

I believe something like that should do it:

rsync -av source destination --exclude="*.123"

Explaining it a little bit:

  • -a means archive mode. It's the default option for backups, since it is recursive and preserves not only structure, but also timestamps and owners.
  • -v means verbose... the command should print more information about your copy. Is useful to see if everything is going as expected.
  • --exclude is self-explanatory... it excludes from your backup the files matching the pattern.

You can also use rsync later to just copy over the modified files. This is specially useful for backups, where you usually don't want to copy everything again.

Have a look at rsync man page (man rsync) to have a better look at it's options.

  • 1
    rsync is the tool for transferring files, copying /home, backing up locally or over a network. It's worth using with this small job just to you'll know how to use it in the future! – Marc Jan 5 '14 at 21:33
  • 1
    You need to quote the "*.123" to make sure the shell doesn't interpret it instead of rsync, otherwise if you have a file or files with a .123 extension in the current directory, the shell will substitute it's/their name(s). – psusi Jan 5 '14 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.