2

Today i tried to import some MP3 Files from an external drive to my music folder, when i noticed that many of my tags are getting wrong interpreted. For example, files with letters such as á,ó,í,ö,ä etc. are shown as a question mark within a rectangle, something like this:�

All i did is mv all mp3 files from the external fat32 drive to my own, which is linux. Is there a way to remove this "special character" i.e. with a letter? What i unsuccessfully tried was sed -e 's/\?/ae/g' like this:

id3v2 -l song.mp3 | grep Artist | cut -d ':' -f 2 | sed -e 's/\?/ae/g'

What i realized when reading this Link, that some of those letters as ä,ö,á are interpreted with digits such as \341. I think this has something to do with the FAT32 to linux transcoding, but i'm not sure at all. Somebody knows how to replace them correctly with sed - other solutions welcome ;-). Thanks for your suggestions!

JFP
  • 21
  • 1
  • 2
  • 1
    Maybe you will be interested in `iconv`. – ДМИТРИЙ МАЛИКОВ Jun 26 '12 at 19:57
  • Is this a problem with the *names of the files* or with the *tags inside the files*? I answered assuming you meant the former, but you may actually mean the latter. – zwol Jun 26 '12 at 20:12
  • can i integrate iconv in my string above (replacing sed)? @Zack the transcription error refers to the _tag within my mp3_ file. – JFP Jun 27 '12 at 19:47
  • As a diagnostic, you could try `id3v2 -l song.mp3 | iconv -f cp1252 -t utf-8`. If that outputs the accented letters correctly, we know what's wrong. We'd then have to figure out how to correct the tags in the files, which I don't know how to do offhand. – zwol Jun 27 '12 at 19:53
  • ok sorry, i thought i'd already tried that. It worked! – JFP Jun 27 '12 at 19:55

2 Answers2

3

I'm unsure if this reverse-logic sed expression will work as answer to your sed question, but give it a try:

sed -re 's/[^a-zA-Z0-9]+//g'

Which takes one or more instances of every char thats not a-z. A-Z, 0-9 and removes it. (Sometimes it's the easiest way to do things when you have a limited set of characters to allow, but unknown amount of non-allowed chars. You probably have to add more chars to the expression that you want to allow.)

Jite
  • 4,250
  • 1
  • 17
  • 18
  • thanks, i just gave it a try but it did not work out. What happenes is that spaces and other characters disappear, but the unknown character remains. – JFP Jun 27 '12 at 18:18
0

The tags are in your mp3 files? If so, I'd avoid running sed on binary files...

ewindes
  • 790
  • 7
  • 17