GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
13 MIN READ TIME

Answers

Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com

Neil Bothwick is going to reply to more queries in 2025 than ever before.

Q Bits of music

I ripped all my CDs into 128kb/s MP3s, using Audiograbber on a Windows laptop at the time. I’ve since ripped some of my most listened to albums in 320kb/s and now I’m seeing the benefits of FLAC. I am trying to find out which CDs need to be ripped again in 320 and FLAC. All my ripped CDs are in their respective folders and then in a base folder called Music.

I am looking for a way to write a script that will get the bitrate from the MP3 and echo it to the screen, which I can then echo to a file. Ideally I will run it once and it will recursively go into each folder and check for MP3s and add them to the list.

I have MediaInfo installed and I’m sure I can use it. It has a command-line version and will display the bitrate, but whether or not I can display just the filename or folder name and bitrate is another thing.

I would really only have to read one file in the folder and then I would know if the folder is 128kb/s or 320.

Any suggestions? I am not averse to a bit of programming, and I have used C and Python in the past. I’m sure a Bash script would be a hell of a lot handier to do.

A MediaInfo (https://mediaarea.net/en/mediainfo) is what we first thought of when reading this. It does have options to output specific information about a file, rather than just dumping the entire file details to your terminal. Its way of working seems a little odd, as though it was not designed by someone whose main operating system was Linux. There is no man page, and little documentation on the website, but the following is a good starting point:

$ mediainfo --Help

What you need is the --Output option:

$ mediainfo --Output=Audio\;%BitRate% filename

The backslash is needed because the semicolon is a reserved character in Linux shells. It is possible to have MediaInfo also output the filename, but you cannot control the order of items output and, for reasons we will come to, it is better to output the bitrate first. As you want to recurse through your entire music directory, you should use the find command to generate a list of MP3 files:

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
February 2025
VIEW IN STORE

Other Articles in this Issue


LINUX FORMAT
LINUX FORMAT
The #1 open source mag Future Publishing Limited,
WELCOME
MEET THE TEAM
This issue we’re looking at more open AI and machine-learning concepts, so what’s the most interesting thing you’ve found yourself using AI for?
Inside AI
Of all the questions surrounding AI, we do
REGULARS AT A GLANCE
Is Valve starting an OS war with Microsoft?
Valve branding hints at SteamOS expansion, while Microsoft’s TPM requirements frustrate users. Could this spark a shift towards Linux?
ChromeOS upgrades
Rumours of Google’s plans to merge ChromeOS into Android mean Apple’s tablet dominance could be challenged. But what about existing Chromebooks?
Intel announces Arc B series
Battlemage is accompanied by open source drivers.
MAKE A DATE!
Italo Vignoli is one of the founders
CHANGES IN STORE?
Dave Stokes is a technology evangelist at
Linus hates CPU feature levels
Linux creator slams “completely broken” x86_64 feature levels.
Paid software on Flathub?
Gnome seeks a program manager to set up payments.
Mozilla pixel brand refresh
Non-profit hopes to “reclaim the internet” with a new logo.
Distro watch
What’s behind the free software sofa?
MEDIA UPDATE
Mark Filion is a senior marketing manager
ELECTRIC THEMES
Jon Masters is a kernel hacker who’s
Kernel Watch
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to.
Mailserver
WRITE TO US Do you have a burning
YOUR DIGITAL ISSUE ACCESS
Linux Format print subscribers can now access digital back issues two ways! * Who’s a lucky bunch of readers?!
HotPicks
Sweet Home 3D Duplicati VeraCrypt ImageMagick WhatSie Topgrade-rs Ark KTuberling PortProton MuseScore LosslessCut
FIREWALL YOUR HOME!
CREDIT: Magictorch LXF325 will be on sale Tuesday
REVIEWS
AMD Ryzen 7 9800X3D
AMD forges the unquestioned gaming champ, Paul Alcorn finds.
GhostBSD 24.10.1
Nate Drake determines whether this is the Casper of the BSD world or whether your system will be haunted by bugs.
Tucana Linux 3.1
Nate Drake is left scratching his head over this latest distribution for building your own OS (almost) from scratch.
Br OS 24.10
Nate Drake delves into this colourful Latin American distro, which couples KDE Plasma 6 with its very own dock.
BackBox 9
After two years, Nate Drake finally gets to review this Ubuntu-based pentesting distro. Can it contend with greats like Kali?
ROUNDUP
Roundup
ChatGPT Claude HuggingChat Microsoft Copilot Google Gemini
The verdict
AI chatbots
GET INSIDE OPEN AI!
GET INSIDE OPEN AI!
Long-suspected chatbot Jonni Bidwell invokes all his neural networks to harness the power of open source AI.
Pi USER
Multiple Pi 5 releases in time for 2025
It seems there are Pis flying at us faster than we can dodge them all!
Emteria OS
Les Pounder has installed Android on countless Raspberry Pis (and even an O2 Joggler) but Emteria has to be the easiest way ever.
Pi Pico 2 W
Feeling rather full after Christmas, it seems Les Pounder can still manage another wafer-thin Pi.
Raspberry Pi 500
The keyboard is the computer again! Les Pounder takes the updated homage to retro home computers for a spin.
Capture images and video with Picamzero
CAMERA
IN DEPTH
BUILD A STEAM DECK
John Knight tries one of several SteamOS imitations and is overwhelmed by the future possibilities for Linux PC gaming.
TUTORIALS
Hide vital information
Shashank Sharma is a man of many hidden talents. Too bad he’s forgotten the passphrase to unlock them all.
Take back control of your desktop email
Nick Peers takes a fresh look at the venerable email app Thunderbird as it celebrates its twentieth birthday in style, by sending it an ecard.
Boost and bolster your Firefox browsing
Firefox is a powerful web browser, but it lags behind on some of the latest features. Michael Reed explores how to add them.
Edit OpenStreetMap like a pro contributor!
JOSM
The rise and fall of pen plotters
RETRO DEVICES
Enhance your keyboard with full RGB lighting!
OPENRGB
ADMINISTERIA
Top New Year’s sysadmin resolutions
Rather than try any silly new diet fads, this year Stuart Burns has decided to learn some new classic terminal tricks.
INTEL’S LAKES, COVES & SKIES
Strapping on his hiking boots, Jarred Walton walks us through Intel’s new outdoor-inspired architectures.
CODING ACADEMY
CODING ACADEMY Space Invaders
Nate Drake invites you to stave off the alien menace by coding your very own Space Invaders clone in classic BBC Basic.
Code an in-app search engine with Xapian
David Bolton shows how to add a search engine to your Python applications using the Xapian open source code library.
Chat
X
Pocketmags Support