Bulk Extension Renamer - bash
As a quick counter-point to my earlier PowerShell script , here's my equivalent in bash: 1: #!/bin/bash 2: 3: if [ $# -lt 2 ]; then 4: echo -e "\e[33mUsage: $0 <current extension> <new extension>\e[0m" 5: exit 1 6: fi 7: 8: for fileName in *.$1; do 9: newFileName=${fileName/.$1/.$2} 10: if [ -f "$newFileName" ]; then 11: echo -e "\e[31mNot renaming \e[1m$fileName\e[22m to \e[1m$newFileName\e[22m -- File exists." 12: elif [ -d "$newFileName" ]; then 13: echo -e "\e[31mNot renaming \e[1m$fileName\e[22m to \e[1m$newFileName\e[22m -- Is a directory." 14: else 15: if [ -w "$fileName" ]; then 16: mv "$fileName" "$newFileName" 17: echo -e "\e[1;32m$fileName\e[22m renamed to \e[1m$newFileName\e[0m" 18: else 19: ...