Skip to content

Instantly share code, notes, and snippets.

@oozman
Created October 19, 2018 11:43
Show Gist options
  • Save oozman/579b4619af7a79413920bbda96a585ac to your computer and use it in GitHub Desktop.
Save oozman/579b4619af7a79413920bbda96a585ac to your computer and use it in GitHub Desktop.
Random file renamer.
#!/bin/bash
chars=( {a..z} {A..Z} {0..9} )
function rand_string {
local c=$1 ret=
while((c--)); do
ret+=${chars[$((RANDOM%${#chars[@]}))]}
done
printf '%s\n' "$ret"
}
for file in {~/YOUR/PHOTO/FOLDER/}*
do
ext=$(echo ${file} | sed 's,^.*\(\.[^\.]*$\),\1,')
mv "$file" {~/YOUR/PHOTO/FOLDER/}"$(rand_string 10)"${ext}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment