Created
September 24, 2015 13:42
-
-
Save pwin/0444f48b05a0c372ada6 to your computer and use it in GitHub Desktop.
Linux Bash command line routine for splitting large folders into folders of up to n files [useful for Github which doesn't allow more than 1000 files per folder]
This file contains 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
let fileCount=1000 | |
let dirNum=1 | |
for f in * | |
do | |
[ -d $f ] && continue | |
[ $fileCount -eq 1000 ] && { | |
dir=$(printf "%03d" $dirNum) | |
mkdir $dir | |
let dirNum=$dirNum+1 | |
let fileCount=0 | |
} | |
mv $f $dir | |
let fileCount=$fileCount+1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From http://ubuntuforums.org/showthread.php?t=976447