Created
October 19, 2018 11:43
-
-
Save oozman/579b4619af7a79413920bbda96a585ac to your computer and use it in GitHub Desktop.
Random file renamer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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