Last active
August 29, 2015 14:12
-
-
Save cmprescott/7ec176a03dd5f58419df to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# FILE: | |
# prepend_random_num.sh | |
# ABOUT: | |
# Prepends a random number between 1-65000 and an underscore to all files of specified type | |
# Runs on Mac OSX & Linux | |
# EXAMPLE: | |
# $ ls | |
# a.jpg b.jpg | |
# $ sh prepend_random_num.sh jpg | |
# $ ls | |
# 138_b.jpg 8474_a.jpg | |
for file in *.$1 | |
do | |
rand=$(jot -r 1 1 65000 || shuf -i 1-65000 -n 1) | |
mv "$file" "$rand"_"$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment