批处理子文件夹中包含 sox 的 wav 文件

发布于 2025-01-20 12:20:31 字数 1466 浏览 4 评论 0原文

我有一个批处理脚本文件,将现有wav文件转换为单声道文件,称为“ mono”

code

@echo off && cd /d "%~dp0"

2>nul mkdir "Mono"
set "_sox=C:\Program Files (x86)\sox-14-4-2\sox.exe"

for %%i in ("*.wav") do "%_sox%" -S "%%~fi" "Mono\%%~ni.wav" channels 1

我必须放置此.bat 代码>在我想要转换的文件夹中的文件。我的文件夹结构正在扩展,我必须手动浏览每个文件夹,放置.bat文件并运行脚本以获取所得的单声道文件。

这是我的文件夹结构的一个示例:

Main Folder
    |
    |______fold1
    |        |_____file1.wav
    |        |_____file2.wav
    |
    |______fold2
    |        |_____file1.wav
    |        |_____file2.wav
    |
    |______fold3
             |_____file1.wav
             |_____file2.wav

使用扩展的文件夹结构,我想将.bat文件放在主文件夹中,运行脚本,脚本将通过每个子文件夹,创建每个子文件夹中的“单声道”文件夹,然后将转换后的单wav文件放入其中。这应该是带有转换的单声道文件的更新文件结构:

Main Folder
    |
    |______fold1
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav
    |______fold2
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav
    |______fold3
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav

请让我知道如何修改.bat文件以完成此任务。谢谢!

I have a batch script file that converts existing wav files to Mono wav files to a created folder called "Mono"

CODE

@echo off && cd /d "%~dp0"

2>nul mkdir "Mono"
set "_sox=C:\Program Files (x86)\sox-14-4-2\sox.exe"

for %%i in ("*.wav") do "%_sox%" -S "%%~fi" "Mono\%%~ni.wav" channels 1

I have to place this .bat file in the folder that I want converted. My folder structure is expanding and I have to go through each folder manually, place the .bat file and run the script to get the resultant mono files.

Here is an example of my folder structure:

Main Folder
    |
    |______fold1
    |        |_____file1.wav
    |        |_____file2.wav
    |
    |______fold2
    |        |_____file1.wav
    |        |_____file2.wav
    |
    |______fold3
             |_____file1.wav
             |_____file2.wav

With the expanding folder structure, I wanted to place the .bat file in the Main Folder, run the script, and the script will go through each subfolder, create the "Mono" folder in each subfolder and place the converted mono wav files in there. This should be the updated file structure with the converted mono files:

Main Folder
    |
    |______fold1
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav
    |______fold2
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav
    |______fold3
    |        |_____file1.wav
    |        |_____file2.wav
    |        |_____Mono
    |                |______file1.wav
    |                |______file2.wav

Please let me know how to modify the .bat file to accomplish this task. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷途知返 2025-01-27 12:20:31

这就是我的方式:

@ECHO OFF
SET "_sox=C:\Program Files (x86)\sox-14-4-2\sox.exe"

FOR /F "usebackq delims=" %%A IN (`DIR /B "%~dp0"`) DO (
    MKDIR "%~dp0\%%A\Mono" 2> NUL
    FOR /F "usebackq delims=" %%B IN (`DIR /B "%~dp0\%%A\*.wav"`) DO (
        "%_sox%" -S "%~dp0\%%A\%%B" "%~dp0\%%A\Mono\%%~nB.wav" channels 1
    )
)

dir /b < /code>列出了指定文件夹中的每个文件和文件夹。

对于它找到的每个文件夹,它将在其中创建一个单声道文件夹,然后为每个.wav找到的文件运行SOX命令。

希望这会有所帮助。爱你的名字顺便说一句

This is how I would do it:

@ECHO OFF
SET "_sox=C:\Program Files (x86)\sox-14-4-2\sox.exe"

FOR /F "usebackq delims=" %%A IN (`DIR /B "%~dp0"`) DO (
    MKDIR "%~dp0\%%A\Mono" 2> NUL
    FOR /F "usebackq delims=" %%B IN (`DIR /B "%~dp0\%%A\*.wav"`) DO (
        "%_sox%" -S "%~dp0\%%A\%%B" "%~dp0\%%A\Mono\%%~nB.wav" channels 1
    )
)

DIR /B lists every file and folder within the specified folder.

For each folder it finds, it will create a Mono folder within it, and then run the sox command for each .wav file found.

Hope this helps. Love your name btw

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文