Skip to content

Instantly share code, notes, and snippets.

@MewX
Created April 5, 2022 13:11
Show Gist options
  • Save MewX/4fff673387bf7e4d150a6b7d6724c4cb to your computer and use it in GitHub Desktop.
Save MewX/4fff673387bf7e4d150a6b7d6724c4cb to your computer and use it in GitHub Desktop.
Split files in one directory into two directories randomly.
from_dir="."
save_dirs=("dir1" "dir2")
ls "$from_dir" |sort -R |tail -$N |while read file; do
echo mv "\"$from_dir/$file\"" "${save_dirs[RANDOM%${#save_dirs[@]}]}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment