Skip to main content
missing suffix
Source Link
Philippos
  • 13.8k
  • 2
  • 42
  • 82

You can loop through all files with a for loop, then remove the suffix using ${variable%suffix} syntax and finally replace that middle part with the ${variable/search/replace} syntax:

for file in /opt/data/*/*; do
  file="${file%xy}"
  mv "$file""$file"xy "${file/dig/cur}mp3"
done

You can loop through all files with a for loop, then remove the suffix using ${variable%suffix} syntax and finally replace that middle part with the ${variable/search/replace} syntax:

for file in data/*/*; do
  file="${file%xy}"
  mv "$file" "${file/dig/cur}mp3"
done

You can loop through all files with a for loop, then remove the suffix using ${variable%suffix} syntax and finally replace that middle part with the ${variable/search/replace} syntax:

for file in /opt/data/*/*; do
  file="${file%xy}"
  mv "$file"xy "${file/dig/cur}mp3"
done
Source Link
Philippos
  • 13.8k
  • 2
  • 42
  • 82

You can loop through all files with a for loop, then remove the suffix using ${variable%suffix} syntax and finally replace that middle part with the ${variable/search/replace} syntax:

for file in data/*/*; do
  file="${file%xy}"
  mv "$file" "${file/dig/cur}mp3"
done