Created
April 15, 2024 12:21
-
-
Save geekodour/60dff814035ffe9d3c1bfc6c97d897e0 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
#!/usr/bin/env bash | |
# Specify the directory where you want to perform the renaming | |
directory="." | |
# Move to the specified directory | |
cd "$directory" || exit | |
# Loop through all files in the directory | |
for file in *; do | |
extension="jpg" | |
# Check if the extension appears twice | |
if [[ "$file" == *."$extension"."$extension" ]]; then | |
# Extract the filename without the extra extension | |
filename="${file%.jpg.jpg}" | |
# Rename the file | |
mv "$file" "$filename.$extension" | |
echo "Renamed $file to $filename.$extension" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment