As an example, I have a bunch of .ogg
files in my Downloads
directory, so... to batch convert a bunch of .ogg
files in a given directory to .mp3
files in the same directory, I did the following in Terminal:
cd Downloads
for f in *.ogg; do ffmpeg -i "$f" "${f%.*}.mp3"; done
This created an .mp3
file for each .ogg
file I have in my Downloads directory.
So, using your directory path, do the following:
cd ~/Downloads/Minecraft+Sound+Pack+1.13/step
for f in *.ogg; do ffmpeg -i "$f" "${f%.*}.mp3"; done
That said and considering your dealing with a sound file pack you downloaded from the Internet, Minecraft+Sound+Pack+1.13.zip, which contains 131 directories, some nested 3 or more deep, and 1406 .ogg
files, of which some of the filenames are the same, I would handle the situation with the following conditions in mind.
- I downloaded the
Minecraft+Sound+Pack+1.13.zip
file from the Internet.
- Expanded the zip archive by double-clicking on it in my Downloads folder in Finder. Note that this is because I do not let the Browser unzip downloaded archive files. This also retains a copy of the zip archive in case I still need it afterwards.
With that done, I used the following example bash script to convert each .ogg
file within the hierarchal folder structure to an .mp3
file at the same location. Then delete the .ogg
files, as I still have the original zip archive.
#!/bin/bash
# s="/Path/To/Source/Files"
s="$HOME/Downloads/Minecraft+Sound+Pack+1.13"
for d in $(find "$s" -type f -iname '*.ogg' | sed -E 's|/[^/]+$||' | sort -u); do
cd "$d"
for f in *.ogg; do
ffmpeg -i "$f" "${f%.*}.mp3"
rm "$f"
done
done
- You only need to change the value of
s="..."
as or if needed and as a general rule I like to use $HOME
in place of ~
.
Note that this is just how I choose to deal with the situation in the moment and there are many different ways that a script could be written. This however I believe achieves the end goal of having the hierarchal folder structure of the 131 directories intact with the 1406 converted .mp3
files.
By the way... On my old MacBook Pro, (Retina, 15-inch, Early 2013) 2.8 GHz Intel Core i7, it took just under 9 minutes to process the 1406 .ogg
files.
ffmpeg -i file_name.ogg file_name.mp3