Advertisement
cd62131

mv files by size

Jun 5th, 2019
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.26 KB | None | 0 0
  1. #!/bin/bash
  2. DIRNAME='dirXXXXX'
  3. to=$(mktemp -p . -d "$DIRNAME")
  4. size=0
  5. for f in *.jpg *.png *.jp2; do
  6.   f_size=$(stat -c %s "$f")
  7.   mv "$f" "$to"
  8.   ((size += f_size))
  9.   if ((size > 20000000)); then
  10.     to=$(mktemp -p . -d "$DIRNAME")
  11.     size=0
  12.   fi
  13. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement