Debian下的Sox批处理过程 [英] Sox batch process under Debian

查看:170
本文介绍了Debian下的Sox批处理过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对文件夹中的一堆wav文件进行重新采样.

我的脚本是这样的:

for f in *.wav; do sox $f -r 48000 ${f%%%.wav}.wav; done

控制台给我这个错误:"sox FAIL格式:无法打开输入文件"90.wav":没有这样的文件或目录",依此类推,还有放置在该文件夹中的300个文件. /p>

如何对该文件进行批处理?为什么会给我这个错误?

非常感谢!

解决方案:

for i in *wav; do echo $i; sox $i -r 48000 ${i%%.wav}r.wav; done

解决方案

摘要:这是引用符号

问题在于双引号:

for f in *.wav; do sox $f -r 48000 ${f%%%.wav}.wav; done

以上双引号是非标准的.为了使它们能够被外壳正确处理,必须使用标准的ASCII引号:

for f in ./*.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done

此外,请注意,${f%%%.wav}将从输入文件名的末尾删除所有出现的%.wav. ${f%%%.wav}.wav在删除任何%.wav后缀之后,在末尾再添加一个.wav.您可能会在这里想要其他东西.

验证

根据问题,使用错误引号字符,观察错误消息:

$ for f in *.wav; do sox $f -r 48000 ${f%%%.wav}.wav; done
sox FAIL formats: can't open input file `90.wav': No such file or directory

请注意,错误消息中的文件名在文件名周围显示了两组引号.这是您根据问题中的错误消息看到的内容.外部单引号由sox提供.内部双引号是命令行上提供的有趣的引号字符.由于它们是非标准字符,因此外壳程序将其保留在原处,并将其传递给sox命令.

虽然文件90.wav存在,但是不存在名称为90.wav的文件.因此,错误.

结论

对于shell命令,请粘贴到标准ASCII字符.

如果使用精美的文字处理编辑器键入了shell命令,而该文字处理编辑器替代了印刷精美但非标准的字符,则很容易发生此问题.正如三方指出的那样,当从印刷样式不合适的网站进行复制和粘贴时,也会发生这种情况.

I want to resample a bunch of wav files that I got on a folder.

My script is this:

for f in *.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done

The console give me this error: "sox FAIL formats: can't open input file `"90.wav"': No such file or directory" and so on with the 300 files that are placed on that folder.

How can I batch processing right this files? Why is it giving me this error?

Thanks a lot!

Solution:

for i in *wav; do echo $i; sox $i -r 48000 ${i%%.wav}r.wav; done

解决方案

Summary: It is the quote symbols

The problem is with the double-quotes:

for f in *.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done

The double-quotes above are non-standard. For them to be properly processed by the shell, the standard ASCII quote symbol must be used:

for f in ./*.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done

As an aside, note that ${f%%%.wav} removes any occurrences of %.wav from the end of the input file name. ${f%%%.wav}.wav adds one .wav back on to the end after removing any %.wav suffixes. You likely want something else here.

Verification

Using the bad quote characters, as per the question, observe the error message:

$ for f in *.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done
sox FAIL formats: can't open input file `"90.wav"': No such file or directory

Note the file name in the error message is shown with two-sets of quotes around the file name. This is what you saw as per the error message that in the question. The outer single-quotes are supplied by sox. The inner double-quotes are the funny quote characters provided on the command line. Because they are non-standard characters, the shell left them in place and passed them to the sox command.

While the file 90.wav exists, no file by the name of "90.wav" exists. Hence, the error.

Conclusion

Stick to standard ASCII characters for shell commands.

This issue can easily happen if the shell commands are typed in using a fancy word-processing editor that substitutes in typographically-pretty but non-standard characters. As tripleee points out, it can also happen when copying-and-pasting from the websites with inappropriate typographical styling.

这篇关于Debian下的Sox批处理过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆