Created
November 6, 2015 20:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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