Skip to content

Instantly share code, notes, and snippets.

@levhita
Created November 6, 2015 20:02
Show Gist options
  • Save levhita/30549e06432f7209263a to your computer and use it in GitHub Desktop.
Save levhita/30549e06432f7209263a to your computer and use it in GitHub Desktop.
Splits bulk files inside a folder into individual 001, 002. etcc folders with 800 files each. Use it so i can browse a lot of importes images without breaking ubuntu.
if [ ! -d "$1" ]; then
echo "Directory doesnt exists"
exit
fi
cd $1
fileCount=800
dirNum=1
for f in *
do
[ -d $f ] && continue
[ $fileCount -eq 800 ] && {
dir=$(printf "%03d" $dirNum)
echo $dir
mkdir $dir
dirNum=$((dirNum+1))
fileCount=0
}
mv $f $dir
fileCount=$((fileCount+1))
done
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment