简体   繁体   中英

How to take actual files (without naming it precisely in the script) in the current directory and to process them?

I'm trying to create a script to reduce volume and then merge 5 audio files into one. To process it, I'm using the sox command line.

The problem is, I have to rename all the files in the current directory to match their names with those inside the script. Is there a solution to automatically take these 5 audio files in the current directory and process them with my script ?

Therefore, I will not spend too much time to rename each file.

Thanks a lot !

#!/usr/bin/env bash

cd "$(dirname "$0")"

sox -v 0.5 Track-1.aif Track-10.aif
sox -v 0.5 Track-2.aif Track-20.aif
sox -v 0.5 Track-3.aif Track-30.aif
sox -v 0.5 Track-4.aif Track-40.aif
sox -v 0.5 Track-5.aif Track-50.aif

sox -m Track-10.aif Track-20.aif Track-30.aif Track-40.aif Track-50.aif Mix-orchestrate-1.aif

what about this?

cd "$(dirname "$0")"
mergecmd='sox -m'
for f in $(find . -type f -name "*.aif" | sort -V); do
    sox -v 0.5 "$f" "$f.voldown"
    mergecmd.=" $f.voldown"
done
mergecmd.=" Mix-orchestrate-1.aif"
exec "$mergecmd"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM