title: Split a folder into multiple subfolders in terminal/bash script
body: <p>I have several folders, each with between 15,000 and 40,000 photos. I want each of these to be split into sub folders - each with 2,000 files in them.</p>
  
  <p>What is a quick way to do this that will create each folder I need on the go and move all the files?</p>
  
  <p>Currently I can only find how to move the first x items in a folder into a pre-existing directory. In order to use this on a folder with 20,000 items... I would need to create 10 folders manually, and run the command 10 times.</p>
  
  <pre><code>ls -1  |  sort -n | head -2000| xargs -i mv "{}" /folder/
  </code></pre>
  
  <p>I tried putting it in a for-loop, but am having trouble getting it to make folders properly with mkdir. Even after I get around that, I need the program to only create folders for every 20th file (start of a new group). It wants to make a new folder for each file.</p>
  
  <p>So... how can I easily move a large number of files into folders of an arbitrary number of files in each one?</p>
  
  <p>Any help would be very... well... helpful!</p>