Skip to content

Instantly share code, notes, and snippets.

@luckylittle
Created May 30, 2020 00:07
Show Gist options
  • Save luckylittle/59bc20d5172413c666841e96c04b9647 to your computer and use it in GitHub Desktop.
Save luckylittle/59bc20d5172413c666841e96c04b9647 to your computer and use it in GitHub Desktop.
Bash script to randomize filenames (to 6 alphanumeric characters)
#!/bin/bash
for x in $(ls -1); do mv {${x},$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)}; done
# Before:
# ~ ls
# ~ IMG_20200522_225920.jpg IMG_20200522_230114.jpg IMG_20200522_230302.jpg
# After:
# ~ ls
# ~ 14pkJd 4ld2t9 6foTRm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment