dd388/crals

Rename WAV files by substituting one string for another within the existing filename

Closed this issue · 2 comments

for i in *.wav; do mv “$i” “$(echo $i | sed ’s/MAC/MN/g’)”; done

This is a supplement to the command to append file extensions. This works within the full filename string, instead of only at the beginning or end. It uses “sed” to do this substitution work. The ‘s’ tells sed that we want it to perform a substitution. The "/" characters serve as separators between the old and new values we want to find/replace. First we define the old value we want to replace. In this case “MAC”. Then we define the new value we want to substitute for the old value. In this case “MN”. The ‘g’ tells sed that we want it to do this globally in the string, i.e., every time it sees MAC it replaces with MN. It is essentially a find and replace action.

  • Bert
dd388 commented

This is great. I'll get it added to the site as soon as I'm able. Thank you!

dd388 commented

Added! d9af6a1