Lame-script

smbdyclldlcs

smbdyclldlcs

Doppel-As
Ich (kompletter newbie in sachen sh-scripte) würde mir gern ein script basteln, das alle dateien in einem verzeichnis ausliest und sie an lame übergibt, damit dieses sie encodieren kann. soweit bin ich schon dass man mit dir alle dateien in einem ordner anzeigen lassen kann und dass man die ausgabe irgendwie in ne variable stecken müsste. Wie man das nun umsetzt und lame klarmacht, dass er jede datei einzeln nehmen und encodieren soll, weiß ich halt nicht. Bin auch mit nem Link zufrieden, wo das ganze erklährt wird, hab bei google nix finden können.
 
mit find sollte das gehen

Hallo zusammen,

wenn ich mich nicht irre, dann ist das was du vor hast kein großer akt. ein einfaches

find . -name suchkriterium -exec lame(????) ;

sollte doch dein problem lösen?!

Korrigiert mich, sollte ich falsch liegen.

Gruß
 
Hallo zusammen,

wenn ich mich nicht irre, dann ist das was du vor hast kein großer akt. ein einfaches

find . -name suchkriterium -exec lame(????) ;

sollte doch dein problem lösen?!

Korrigiert mich, sollte ich falsch liegen.

Gruß

Hallo
Ist schon richtig, nur wird es bei Leerzeichen vor die Wand laufen.
Wie das geht ist hier hundertemal erläutert.
Einfach mal die Boardsuche verwenden.
Stichwort while read oder xargs...

Gruß Wolfgang
 
Und was ist mit
Code:
cd $DEINDIR
lame *
direkt in die bash reinhauen? Ich machs so zumindest mit bladeenc. Du kannst für sowas stupides aber auch gerne ein script basteln ;)
 
Und was ist mit
Code:
cd $DEINDIR
lame *
direkt in die bash reinhauen? Ich machs so zumindest mit bladeenc. Du kannst für sowas stupides aber auch gerne ein script basteln ;)

Damit kannst du aber nur Dateien im aktuellen Verzeichnis bearbeiten.
Unterverzeichnisse oder andere Pfade (von leerzeichen ganz zu schweigen) gehen so nicht.

Gruß Wolfgang
 
das ganze sieht jetzt so aus:
#!/bin/sh
read data
echo $data
cd $data
lame --mp3input -t -b 64 *
das ganze erzeugt folgende meldungen:
tux@KanotixBox:~/Desktop$ lame.sh
skandal
skandal
lame: excess arg Wise_Guys_-_Der_letzte_Martini.mp3
LAME version 3.96.1 (http://lame.sourceforge.net/)

usage: lame [options] <infile> [outfile]

<infile> and/or <outfile> can be "-", which means stdin/stdout.

Try:
"lame --help" for general usage information
or:
"lame --preset help" for information on suggested predefined settings
or:
"lame --longhelp"
or "lame -?" for a complete options list
was läuft da schief?
 
Soweit ich das sehe hast du keinen <outfile> angegeben oder?

Was immer ganz gut geht ist:

Code:
cd <directory>
for mp3 in `ls`
do
   lame <options> $mp3 <outfile>
done

da hat man den vorteil das einem der name der eingabedatei zur verfügung steht und man die endung abschneiden kann um zB.mp3 dranzuhängen.

Gruß
D.
 
Ich hab mir da auch ein paar Scripte gebastelt, vielleicht helfen die Dir weiter:

AudioConverter-Scripte

Ein Script um alle Dateien in einem Verzeichnis zu konvertieren die verschiedene Formate haben, müsste man sich sicher auch leicht basteln können. Allerdings verlangt lame soweit ich weiss als input eine WAV-Datei, so dass alle anderen Formate erst zu WAV gemacht werden müssen.
 
tja... mein script sieht jetzt so aus:
#!/bin/sh
for mp3 in `ls`
do
lame lame --mp3input -t -b 64 $mp3
done
und erzeugt folgende meldungen:
tux@KanotixBox:~/Desktop/skandal$ lame.sh
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
Could not find "lame".
@ brahma:
man kann lame ein bestimmtes inputdateiformat mitteilen, wie ein blick in die manpage verrät:
Input options:
-r input is raw pcm
-x force byte-swapping of input
-s sfreq sampling frequency of input file (kHz) - default 44.1 kHz
--bitwidth w input bit width is w (default 16)
--mp1input input file is a MPEG Layer I file
--mp2input input file is a MPEG Layer II file
--mp3input input file is a MPEG Layer III file
--nogap <file1> <file2> <...>
gapless encoding for a set of contiguous files
--nogapout <dir>
output dir for gapless encoding (must precede --nogap)
--nogaptags allow the use of VBR tags in gapless encoding
es muss also nicht zwingend .wav sein. Bei mir geht es auch eher darum, die bitrate runterzuschrauben, um kleinere dateien zu bekommen.
 
Zuletzt bearbeitet:
for f in /quellordner/*; do lame -B 128 "$f" "/zielordner/$f"; done
 
@ steinex2: dieser code bringt die dateien auf eine größe von durchschnittlich ca. 3 kb und ungefähr 1 sekunde länge... hab keine ahnung was da jetz falsch is...
.
.
.
EDIT (autom. Beitragszusammenführung) :
.

mit
#!/bin/sh
for mp3 in `ls`
do
lame --mp3input -t -b 64 $mp3
done
funktionierts nun. Wie aufmerksamen lesern nicht entgangen sein wird, habe ich im oberen text lame zweimal reingeschrieben... mein fehler, danke madfool. Jetz brauch ich nur noch eine zeile die die leerzeichen in den namen durch underlines ersetzt, sonst kommts zu fehlermeldungen.
 
Zuletzt bearbeitet:
Hallo

Das ist auch kein Akt. Wenn du im Pfad keine Leerzeichen hast, geht schon folgendes:
Code:
find /path -type f -iname "*mp3"|while read file;do echo $file ${file// /_};done
Statt echo halt mv verwenden.

Wenn du Leerzeichen auch im Pfad hast, dann verwende das hier:
(Pfad wird nicht geändert!)
Code:
find /tmp/test -type f -iname "*mp3"|while read file;do newname=$(basename $file);echo $file $(dirname $file)/${newname// /_};done
dto. echo durch mv ersetzen wenn getestet.

Siehe Variablenexpansion der Shell basename dirname!
Gruß Wolfgang
 
Zuletzt bearbeitet:
#!/bin/sh
read pfad
find /$pfad -type f -iname "*mp3"|while read file;do mv $file ${file// /_};done
for mp3 in `ls`
do
lame --mp3input -t -b 64 $mp3
done
Erzeugt die Ausgabe:
mv: angegebenes Ziel „//home/tux/Desktop/skandal/wise_guys_-_skandal.mp3“ ist kein Verzeichnis
[...]
Was muss ich da noch verändern?
 
Zuletzt bearbeitet:
Hallo
Da du offensichtlich den führenden Slash eingegeben hast, verwende find ohne den führenden Slash im Pfad, oder nimm gleich Variante 2 von mir.

Gruß Wolfgang
 
variante 2
#!/bin/sh
find /tmp/test -type f -iname "*mp3"|while read file;do newname=$(basename $file);mv $file $(dirname $file)/${newname// /_};done
for mp3 in `ls`
do
lame --mp3input -t -b 64 $mp3
done
erzeugt die ausgabe:
tux@KanotixBox:~/Desktop/skandal$ '/home/tux/Desktop/skandal/lame.sh'
find: /tmp/test: Datei oder Verzeichnis nicht gefunden
Could not find "Die".
Could not find "Comedian".
Could not find "Harmonists.mp3".
Error reading headers in mp3 input file lame.sh.
Error reading headers in mp3 input file lame.sh~.
Could not find "Wise".
Could not find "Guys".
Wenn ich die vorherige Version ohne den slash nehme, führt das zu:
tux@KanotixBox:~/Desktop/skandal$ '/home/tux/Desktop/skandal/lame.sh'
/home/tux/Desktop/skandal
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_skandal.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_More_than_words.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Ein_Herz_und_eine_Seele.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_Mann_&_Frau.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Der_letzte_Martini_(1).mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_liebe_im_internet.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Die_Comedian_Harmonists.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_flunder_gibt_es_immer_wieder.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_ich_bin_grumpig.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Probier`s_mal_mit_`nem_Bass.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Goldeneye.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Es_Tut_So_Weh.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Maedchen_lach_doch_mal.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/wise_guys_-_sie_ist_die_beste.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/WiseGuys_Skandal_15_Root_Beer_Rag.mp3“ ist kein Verzeichnis
mv: angegebenes Ziel „/home/tux/Desktop/skandal/Wise_Guys_-_Meine_heisse_Liebe.mp3“ ist kein Verzeichnis
Could not find "Die".
Could not find "Comedian".
Could not find "Harmonists.mp3".
Error reading headers in mp3 input file lame.sh.
Error reading headers in mp3 input file lame.sh~.
Could not find "Wise".
Could not find "Guys".
 
Hallo
Ok, ich habe die Quotings vergessen, aber wie supersucker schon sagte, nicht nur abtippen, sondern selbst nachsehen was da wie passiert.

Benutze also einfach Doublequote um alle Variablen.

Gruß Wolfgang
PS Da ich Multimediamuffel bin, habe ich kein lame. Also bitte für diesbezügliche Optionen selbst in der Manpage nachsehen.
 

Ähnliche Themen

[Suche] - Hilfe bei der Überarbeitung eines bash-Scripts

jdk update

grep und Variablen

xargs beschränkt? Script funktioniert nicht...

Script beim Booten starten, but how?

Zurück
Oben