Skip to content

Instantly share code, notes, and snippets.

@Birchwell
Created October 17, 2015 23:55
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