Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Requesting Linux script for lame to compress mp3 files recursively. (Read 10436 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Requesting Linux script for lame to compress mp3 files recursively.

Hi I am Rupesh from India. I have a huge directory of size 93.5 gb with 8500 mp3 files and 2000 sub directories.

All these mp3s are speeches recorded by someone at 64 kbps. I want to compress these files recursively using lame with 16 kbps bit rate and 11050 sample rate.

I have found some guis or front end for lame like lamexp,razorlame,lamefrontend none has options to compress mp3 files recursively at 16 kbps. On searching net I found a script for ffmpeg to compress recursively. I have deleted ffmpeg code and substituted lame code instead of which I am providing below

Code: [Select]
.
@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem // Define constants here:
set "_SOURCE=I:\to convert3"
set "_TARGET=H:\converted\lame4"

rem // Change to source directory temporarily:
pushd "%_SOURCE%" || exit /B 1
rem // Enumerate source files, return paths relative to the source directory:
for /F "delims=" %%F in ('xcopy /L /S /I ".\*.mp3" "%_TARGET%" ^| find ".\"') do (
    echo Currently converting "%%F"...
    rem // Create destination directory, suppress error if it aready exists:
    mkdir "%_TARGET%\%%F\.." 2> nul
    rem // Perform actual file conversion, using paths relative to target directory:
    lame    --abr 16 -m j -q 0 --resample 22.05 --priority 4   "%%F" "%_TARGET%\%%F\..\%%~nF.mp3"
)
echo Completed.
popd

endlocal

The above script runs only on Windows but can't run on Linux and it is better to run the script on Linux.

Please try to convert the above Windows batch script to Linux shell script and post it.

Please try to suggest if you know a front end for lame which can compress mp3 files recursively at 16 kbps.

Regards,
Rupesh.
Regards,
Rupesh.

Re: Requesting Linux script for lame to compress mp3 files recursively.

Reply #1
There is an outline of the  two-step process to avoid overcomplicated scripting
https://www.youtube.com/watch?v=YFcw6H8ht1A
Debate somewhere on this very forums (can't find right now).
PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung

 

Re: Requesting Linux script for lame to compress mp3 files recursively.

Reply #2
I am positive foobar2000 can do this.

Re: Requesting Linux script for lame to compress mp3 files recursively.

Reply #3
There is a tool called pacpl which I have used to convert FLAC/whatever files to mp3s for portable use. It is recursive, and replicates the directory tree --- but I don't think it can be be used to convert and  overwrite in place.

It is quite powerful and option-rich

pacpl home

man pacpl

There is almost certainly a possible single-line "find" command which would do what you want. See the -exec option of find. You'd better have a good backup before experimenting, though!

man find

find searches recursively and does whatever you tell it to do with the results. Be careful: it does what you tell it, whether it was what you wanted or something you absolutely did not want.

That's the nature of command-line Unix/Linux. If you are working with Linux already, then you probably know that already. It is an awful lot safer to copy/convert the directory tree somewhere else, deleting the original files only when you  are sure the conversion has given you what you want. And pacpl should do that for you without scripting or intricate find-command stuff.

EDIT: looks like the script in the video above is using find, but it really hurts my head to watch text stuff on youtube.


The most important audio cables are the ones in the brain