In shell script, just make a loop by the letters of a
up to the letter you want (let’s assume it’s c
):
for i in {a..c}
do
mesclar $i.*
done
This, assuming that in the directory you only have the files you want (if you have any others whose name is a.algumacoisa
, it will also be passed to the command mesclar
). Also, when using $i.*
, the files will be passed in alphabetical order. If you want to restrict the files and control the order, you can switch to:
for i in {a..c}
do
mesclar $(echo $i.{vocal,bateria,melodia,master}.m4a)
done
In the case, the echo
prints the letter, the dot, and then vocal
, bateria
, etc, in this order. That is, the files are passed in the desired order. And I use the syntax of command substitution so that the exit of the echo
is passed to command mesclar
.
If instead of a
, b
, c
, etc, the names can be anything (not necessarily a sequence), you can put them separated by comma.
Also, once you have these names, you can compose the command however you want. Using the example of your comment, would be:
for i in {nome,outronome,maisoutro}
do
mesclar $(echo $i.{melodia,vocal,baixo,bateria}.m4a) -x $i.master.m4a
done
That will call the commands:
mesclar nome.melodia.m4a nome.vocal.m4a nome.baixo.m4a nome.bateria.m4a -x nome.master.m4a
mesclar outronome.melodia.m4a outronome.vocal.m4a outronome.baixo.m4a outronome.bateria.m4a -x outronome.master.m4a
mesclar maisoutro.melodia.m4a maisoutro.vocal.m4a maisoutro.baixo.m4a maisoutro.bateria.m4a -x maisoutro.master.m4a
In Python the idea is similar, just use one of the many ways of calling external processes to call the command. Example with os.system
:
import os
files = ['vocal', 'bateria', 'melodia', 'master']
for i in 'abc':
params = ' '.join(f'{i}.{file}.m4a' for file in files)
os.system(f'mesclar {params}')
Or, with a list of names and the command indicated in the comments:
import os
files = ['melodia', 'vocal', 'baixo', 'bateria']
for i in ['nome', 'outronome', 'maisoutro']:
params = ' '.join(f'{i}.{file}.m4a' for file in files)
os.system(f'mesclar {params} -x {i}.master.m4a')
That will call the commands:
mesclar nome.melodia.m4a nome.vocal.m4a nome.baixo.m4a nome.bateria.m4a -x nome.master.m4a
mesclar outronome.melodia.m4a outronome.vocal.m4a outronome.baixo.m4a outronome.bateria.m4a -x outronome.master.m4a
mesclar maisoutro.melodia.m4a maisoutro.vocal.m4a maisoutro.baixo.m4a maisoutro.bateria.m4a -x maisoutro.master.m4a
I suggest removing the python tag as it is Shel script.
– Pablo