Advertisement
cd62131

move files

Mar 11th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #!/bin/bash -x
  2. typeset -g DIR=$1
  3. typeset -ig files=$(ls -v ${DIR} | wc -l)
  4. typeset -i i=1
  5. for (( ; ; i++)); do
  6.   mkdir -p 'Directory_'${i}
  7.   if (( i * 5 >= files )); then break; fi
  8. done
  9. (( i = 1 ))
  10. typeset -i j=0
  11. find ${DIR} -type 'f' | sort -V |
  12. while read; do
  13.   mv -t 'Directory_'${i} ${REPLY}
  14.   if (( ++j % 5 == 0 )); then (( i++ )); fi
  15. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement