0

I have a BASH script I wrote that removes META data off mp3 (etc) then I chop them up to reform them if needed resample the mp3 and reasign the data to make a directory to corraspond to artist / album ...

I got a hold of some mp3's that have non english chars in the middle of the song title. I need to know the best way to remove that middle part leaving both ends of the sting put back together to the title of the song. using exiftool I strip the META data off giving me this output placed into the var-name

 ARTIST1="`exiftool -Artist "$FILENAME" -p '$Artist'`"
 TITLE1="`exiftool -Title  "$FILENAME" -p '$Title'`"
 ALBUM1="`exiftool -Album  "$FILENAME" -p '$Album'`"


first strip... Artist is -> The Stranglers and Friends
first strip... Album is -> Live in
first strip... Title is -> The Raven – With Basil Gabbi

song title in META Data

The Raven – With Basil Gabbi

how would I strip what is between the META data song name to get this instead?

The Raven With Basil Gabbi

where the syntext would look something like this

 newSongName="$( what ever code goes here to strip out that non english sting part )"

so I can write the new string back into the file replacing the old META data with the new string.

Thanks

2
  • Please remember to accept answers that have solved your problem. You have asked 18 questions and have only accepted 2 answers. – terdon Nov 20 '15 at 18:30
  • If any of the existing answers solves your problem, please consider accepting it via the checkmark. Thank you! – Jeff Schaller Apr 23 '17 at 13:01
3

This should get you pretty close:

newSongName=$(echo "$TITLE1" | tr -dc '[:print:]')

It tells tr to delete characters that are not in the print class name. You could experiment with other character classes as needed.

0
2

The string with garbble in it ->

 $ x="The Raven ƒÆ’¢â‚¬â€œ With Basil Gabbi"

this keeps hold of all caps and lower case a-z removes everything else

$ echo ${x//[^A-Za-z ]/}

Leaving the string like this

The Raven With Basil Gabbi

would look like this in the script

title=${TITLE1}
## holds on to normal chars getting rid of the rest
title=${title//[^A-Za-z ]/}
1
  • 1
    Don't forget punctuation that you might want -- commas, apostrophes, periods, etc... – Jeff Schaller Nov 19 '15 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.