I'm trying to figure out the "Linux way" of accomplishing the following task. I have a directory with a bunch of sub-directories, each of which contain multiple files of various filetypes. I can easily narrow that down using the "find" command:

find . -name "*.jpg"

Which would return me a list of all of the files ending in .jpg. In addition (but separately), I can also split a directory into groups of files, 100MB each, with the dirsplit command:

dirsplit --size 100MB -m --expmode 1 .

So, now two questions. First, I'd like to combine the two commands, so that dirsplit acts only on the output of the 'find' command - i.e. it only rearranges those JPG's, instead of rearranging everything. Is it possible to pipe into dirsplit?

The second question is the "-m" flag, which you can see here: https://manned.org/dirsplit/15f31c9a will cause dirsplit to actually move the files to the desired folders. My question is whether it's possible to copy instead of move - meaning, leave the files where they are but make an additional copy of them in groups of 100.

Any ideas?


dirsplit -H will give you some more info on the command, including an example of using it with find.

find . -name "*.jpg" -printf "%s %p" | dirsplit -T- --size 100MB --expmode 1 -L

-T- reads filelist from stdin in the form "filename filesize"

-L creates hard links (it seems there is no copy option)

  • Perfect, exactly what I'm looking for. Thank you! – Jake Jun 1 '16 at 17:09

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.