I have files like: alien-skull-2224154.jpg snow-birds-red-arrows-thunderbirds-blue-angels-43264.jpg dead-space-album-1053.jpg
How can I remove in bash the \"ID\" s
This is the final code that works great. Thank you all for your time!
for i in *.jpg; do if [[ -e "${i%-*}.jpg" ]]; then num=1 while [[ -e "${i%-*}-$num.jpg" ]]; do (( num++ )) done mv "$i" "${i%-*}-$num.jpg"; else rename 's/-\d+//' *.jpg fi done