Sox -Mac Automator文件夹用Shell脚本操作,以组合/连接我在Finder中选择的多个WAV文件
我正在使用Mac Automator运行Shell脚本来执行SOX命令,最终将该工作流程为称为“ Combine”的服务。我几乎是一个完整的初学者,但我至少在Automator中确实知道设置Shell:bin/bash并传递输入:作为参数。
我正在尝试使用Finder在同一文件夹中选择多个.WAV文件(尽管不一定是该文件夹中的所有文件,只是我专门选择的文件),并具有Automator指令SOX即可简单地组合/contectate音频文件顺序为一个称为combined.wav的输出文件。例如,如果我在一个文件夹中选择了两个音频文件,每个音频文件每个2分钟,我将获得4分钟的“ combined.wav”文件。
我将下面的脚本作为在Automator中使用的起点,但是该语言的问题是,实际上我选择了我在文件夹中选择的多个文件,而只是将最后一个文件与Compined.wav名称传递,但没有任何内容合并。可以肯定的是,问题在于Sox命令本身,如果我不得不猜测,“ $ f”可能是错误。
#!/bin/bash
for f in "$@"; do
combinedFolder="$(dirname "$f")/Combined"
fileName=$(basename "$f")
if [ ! -d "${combinedFolder}" ]; then
mkdir "${combinedFolder}"
fi
/Applications/SoX/sox "$f" "${combinedFolder}/combined.wav"
done
理想情况下,我很想有两个版本(校正)脚本...一个将组合的脚本放在“合并”子文件夹中,如上文所示,但也很想拥有一个替代(简单)脚本这只是将组合的。wav与我选择的单个输入文件相同的文件夹中,没有子文件夹。
I'm using Mac Automator to run a shell script to execute a SoX command, and I'll ultimately save that workflow as a Service called "Combine". I'm virtually a complete beginner but I do at least know within Automator to set Shell: bin/bash and Pass inputs: as arguments.
I'm trying to be able to select multiple .wav files in the SAME folder using FINDER (though not necessarily ALL files in that folder, just the ones I have specifically selected), and have Automator instruct SoX to simply combine/concatenate those selected audio files sequentially into one output file called combined.wav. For example if I selected two audio files within a folder that were 2 minutes each, I'd end up with a 4 minute "combined.wav" file.
I have the script below as a starting point to use within Automator, but the problem with this language is, instead of actually combining multiple files I have selected within a folder, it just passes the last file through with the combined.wav name but nothing gets combined. Pretty sure the problem lies in the sox command itself, probably the "$f" is the mistake if I had to guess.
#!/bin/bash
for f in "$@"; do
combinedFolder="$(dirname "$f")/Combined"
fileName=$(basename "$f")
if [ ! -d "${combinedFolder}" ]; then
mkdir "${combinedFolder}"
fi
/Applications/SoX/sox "$f" "${combinedFolder}/combined.wav"
done
Ideally I'd love to have two versions of this (corrected) script... one putting the combined.wav output file in a "Combined" subfolder as the text above suggests, but also would love to have an alternate (simpler) script that simply puts the combined.wav in the same folder as the individual input files I've selected, with no subfolder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论