Skip to content

Instantly share code, notes, and snippets.

@yinguobing
Last active July 13, 2021 01:00
Show Gist options
  • Save yinguobing/77857dd79c3dc927e886d9fb34f629a6 to your computer and use it in GitHub Desktop.
Save yinguobing/77857dd79c3dc927e886d9fb34f629a6 to your computer and use it in GitHub Desktop.
Split files in one directory into many dirs.
n=0
for i in *
do
if [ $((n+=1)) -gt 50 ]; then
n=1
fi
todir=../my_file$n
[ -d "$todir" ] || mkdir "$todir"
mv "$i" "$todir"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment