Reputation: 355
I have lot of mp3 files that are in 2 languages so
language 1 is EN/1/1.mp3 .... .. EN/2/12.mp3
language 2 is DE/1/1.mp3 .... .. DE/2/12.mp3
So files are in same subfolder and same name, I want to merge them
EN/1/1.mp3 and DE/1/1.mp3 to be 1 file and to be saved on folder ENDE/1/1.mp3
I use this command
cat EN/1/1.mp3 DE/1/1.mp3 > ENDE/1/1.mp3
and it works but I want something to that will loop this command to all files in all subfolders.
Upvotes: 0
Views: 690
Reputation: 11354
To loop through the files you can use the following, but as @ekaerovets stated, I believe your file will be invalid.
cd EN
for F in */*.mp3; do
mkdir -p ../ENDE/$(dirname $F)
cat $F ../DE/$F > ../ENDE/$F
done
This is assuming you files are all only one sub directory deep. If the tree is deeper then find
would be more appropriate, ie:
cd EN
for F in $(find -type f -name \*.mp3); do
mkdir -p ../ENDE/$(dirname $F)
cat $F ../DE/$F > ../ENDE/$F
done
Upvotes: 2