# Decoding a folder of mp3s in Linux.

**URL:** <https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642>\
**Category:** Great Debates\
**Created:** [October 5, 2003, 2:15am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642 "2003-10-05T02:15:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![black\_rabbit](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@black\_rabbit](https://boards.straightdope.com/u/black_rabbit)\
**Post date:** [October 5, 2003, 2:15am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/1 "2003-10-05T02:15:35Z")

</div>

I’m trying to decode a bunch of (legally acquired, via [emusic.com](http://emusic.com)) mp3s to wavs so that I can then re-encode them to ogg vorbis @ q0.

I wanna have 24 hours of music on a single disc at work, that’s why.

Here’s what I’m doing:

$ for i in \*.mp3; do mpg321 -w `basename $i .mp3`.wav $i; done

Seems to work fine, as long as there are no spaces or special characters in the name. When there _are_ special characters or spaces, however, basename hangs and mpg321 doesn’t touch the file.

Is there a way around this, without going through every file by hand and renaming it? I’ve also tried it as basename “$i” and basename ‘$i’.

---

<div class="post-metadata">

**Author:** ![yosemite](https://avatars.discourse-cdn.com/v4/letter/y/3ab097/32.png) [@yosemite](https://boards.straightdope.com/u/yosemite)\
**Post date:** [October 5, 2003, 2:21am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/2 "2003-10-05T02:21:16Z")

</div>

I think you meant to direct this to GQ and missed your turn? 🙂

That’s basically all I can possibly contribute to this thread. The rest of it might as well be written in Mandarin Chinese as far as I am concerned, since I haven’t got a clue what you are talking about. 😉

---

<div class="post-metadata">

**Author:** ![black\_rabbit](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@black\_rabbit](https://boards.straightdope.com/u/black_rabbit)\
**Post date:** [October 5, 2003, 2:40am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/3 "2003-10-05T02:40:34Z")

</div>

I disagree.

Ummm… yeah. Mods? I’ll take the other forum starting with a “G” for 100, Alex.

---

<div class="post-metadata">

**Author:** ![Some\_Guy](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Some\_Guy](https://boards.straightdope.com/u/Some_Guy)\
**Post date:** [October 5, 2003, 2:51am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/4 "2003-10-05T02:51:25Z")

</div>

You need to double quote the filename globs, otherwise the shell will interpret them as a sequence of two arguments (which is why your command is hanging). Here’s a fixed version:

```auto

#!/bin/bash

for i in "*.mp3"
 do mpg321 -w `basename "$i .mp3"`.wav $i;
 done

```

---

<div class="post-metadata">

**Author:** ![black\_rabbit](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@black\_rabbit](https://boards.straightdope.com/u/black_rabbit)\
**Post date:** [October 5, 2003, 3:33am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/5 "2003-10-05T03:33:53Z")

</div>

Thanks **SG**. It’s working, but now the wavs are getting concatenated in a big giant file called track\_one.mp3. Oh well… I guess I’ll stick to mlame.

---

<div class="post-metadata">

**Author:** ![Shalmanese](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Shalmanese](https://boards.straightdope.com/u/Shalmanese)\
**Post date:** [October 5, 2003, 10:07am UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/6 "2003-10-05T10:07:29Z")

</div>

The problem is that the shell interprets spaces as special charecters. if you put the name in " " or ’ ', the shell will not interpret the argument.

---

<div class="post-metadata">

**Author:** ![Dreaming\_of\_Maria\_Callas](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Dreaming\_of\_Maria\_Callas](https://boards.straightdope.com/u/Dreaming_of_Maria_Callas)\
**Post date:** [October 5, 2003, 2:16pm UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/7 "2003-10-05T14:16:07Z")

</div>

MP3 and Ogg Vorbis are both lossy compression formats. Unless the original MP3s were encoded at some ridiculously high bitrate, the resulting Oggs will sound like crap.

UnuMondo

---

<div class="post-metadata">

**Author:** ![black\_rabbit](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@black\_rabbit](https://boards.straightdope.com/u/black_rabbit)\
**Post date:** [October 5, 2003, 11:42pm UTC](https://boards.straightdope.com/t/decoding-a-folder-of-mp3s-in-linux/205642/8 "2003-10-05T23:42:20Z")

</div>

> [@](#):
>
> \*Originally posted by UnuMondo \*  
> \*\*MP3 and Ogg Vorbis are both lossy compression formats. Unless the original MP3s were encoded at some ridiculously high bitrate, the resulting Oggs will sound like crap.
> 
> UnuMondo \*\*

Given that I’m playing these at less than 10% volume on my crappy work PC speakers, I don’t expect be able to hear a note of Ross “Dr. Knighty” Knight’s bass, let alone appreciate the exquisite distortion he pumps it through. So in this case, having 64kbs oggs re-encoded from 194kbs mp3s that sound subjectively better than, say, 128kbs mp3s ripped straight from the CD, suits my purposes nicely.

Don’t worry; I’m not deleting the originals.

Anyway, mlame works fine, once I edited the source to get rid of that -new-converted-file.mp3 tag it puts at the end of the file names.
