Skip to content

Instantly share code, notes, and snippets.

@Birchwell
Created October 17, 2015 23:55
Show Gist options
  • Save Birchwell/94fa2f3dff1fc2c46728 to your computer and use it in GitHub Desktop.
Save Birchwell/94fa2f3dff1fc2c46728 to your computer and use it in GitHub Desktop.
Divide files in folder into many folders. Customizable by changing number of files.
#!/bin/bash
c=1; d=1; mkdir -p dir_${d}
for file in *
do
if [ $c -eq 600 ]
then
d=$(( d + 1 )); c=0; mkdir -p dir_${d}
fi
mv "$file" dir_${d}/
c=$(( c + 1 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment