Skip to content

Instantly share code, notes, and snippets.

@pwin
Created September 24, 2015 13:42
Show Gist options
  • Save pwin/0444f48b05a0c372ada6 to your computer and use it in GitHub Desktop.
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]
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
@pwin
Copy link
Author

pwin commented Sep 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment