0

How do I copy all the files and folders recursively with the same folder hierarchy. I however want to only copy files under a certain size.

  • The title of your question mentions directories. Do you mean to copy a directory only if the sum of the sizes of all files beneath that directory is under a particular size? – Kusalananda Aug 6 at 14:40
2

You could utilize rsync with the --max-size option.

0

Use find -exec

cd /path/to/source
find . -size -50k -type f -exec cp --parents {} /destination/ \;
0

POSIXly, and assuming file paths don't contain newline characters:

find . -type f -size -10000c | pax -rw /destination/

Here for files smaller than 10000 bytes.

Some find implementations have a -print0 predicate and some pax implementations a corresponding -0 option that cause the file list to be NUL-delimited which would address the newline limitation mentioned above.

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.