Last active
February 22, 2023 01:07
-
-
Save G33N/b10f3be0a997f69b77f8f12da731892e 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 | |
# Set the directory path to rename images | |
directory_path="/path/to/images" | |
# Loop through all image files in the directory and its subdirectories | |
find "$directory_path" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" \) | while read file; do | |
# Generate a UUIDv4 string | |
uuid=$(uuidgen | tr '[:upper:]' '[:lower:]') | |
# Get the file extension | |
extension="${file##*.}" | |
# Rename the file with the UUIDv4 string and original extension | |
mv "$file" "${file%/*}/${uuid}.${extension}" | |
done | |
echo "All image files in $directory_path and its subdirectories have been renamed with UUIDv4 strings." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment