[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux-team] Iteration d'une commande
Ludovic Kuty wrote:
>
> Bonjour,
>
> Il m'arrive assez souvent de vouloir executer une commande
> de maniere iterative dont un ou plusieurs arguments doivent
> etre modifies. Par exemple pour convertir 10 fichiers mp3 en wav
> (meme s'il y a d'autres moyens, c'est juste un exemple):
> mpg123 -b 10000 -s fichier_01.mp3 | sox -t raw -r 44100 -s -w -c2 - audio_01.wav
> ...
> mpg123 -b 10000 -s fichier_10.mp3 | sox -t raw -r 44100 -s -w -c2 - audio_10.wav
>
> Ce qui est fastidieux.
> J'aimerais mieux qqch du style:
> iterate --range 0-10 "mpg123 -b 10000 -s fichier_#1.mp3 | sox -t raw -r 44100 -s -w -c2 - audio_#1.wav"
>
> OU
>
> iterate "mpg123 -b 10000 -s fichier_*.mp3 | sox -t raw -r 44100 -s -w -c2 - audio_#1.wav" ou le #1
> serait remplace par l'occurence courante du *.
> Un peu comme la commande 'mmv' qui fait des deplacements multiples de fichiers.
>
> Qqn a une idee ?
>
> Ludovic Kuty.
Une bonne solution est une boucle en bash. Tu dois donc créer un fichier
script bash...
Et tu utilise la structure suivante :
#!/bin/bash
for i in $(ls *.mp3); do
mpg123 -b 10000 -s $i | sox -t raw -r 44100 -s -w -c2 - audio_01.wav
done
--
First they ignore you...Second they laugh at you...
Then they fight you......And then you win!
(Ghandi)
---------
This message was sent by Majordomo 1.94.3. Please report problems to
manu@rtfm.be. If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.