I have a directory which contain more than thousand images. I want to split the files in to multiple sub directories, each containing 100 files. How do I do this?


the following worked well for me. Open the directory in terminal, and just copy & paste the following script, press enter. sub directories will be created inside having names dir_001, dir_002 and so on.

for f in *; 
    d=dir_$(printf %03d $((i/100+1))); 
    mkdir -p $d; 
    mv "$f" $d; 
    let i++; 
  • This was flagged as low quality. Since you are the OP, could you add an explanation of what you have done? – muru Feb 12 '15 at 16:16
  • done. Have added an explanation. – Aneeez Feb 12 '15 at 18:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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