找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 19582|回复: 5

[文件操作] [已解决]批处理怎样利用ffmpeg合并音频文件?

[复制链接]
发表于 2023-7-26 08:57:07 | 显示全部楼层 |阅读模式
本帖最后由 qd2024 于 2023-7-26 20:52 编辑

想利用ffmpeg合并音频文件。

当前目录下会有相同前缀的文件夹存在,如

外研单词7A_En      外研单词7A_Ch     

以“_”为分界,“_”前面的文件相同,表示为一组,“_”后面的En表示这此文件夹内的音频为文件名对应的【英】文读音。
                                                                                                  Ch表示这此文件夹内的音频为文件名对应的【中】文读音。
En和Ch文件夹下的音频文件都使用相同的文件名,如“0001crayon”

想实现:
将“外研单词7A_En;外研单词7A_Ch”两个文件夹内的同名mp3文件合并到“外研单词7A”文件夹内,
En文件在前,Ch文件在后,即合并后的音频文件,英文在前,中文在后,如果没有“外研单词7A”文件夹,则自动创建。


-------------------------

以“_”为分界,“_”前面的文件相同,表示为一组,如有多组存在,则依先后分另进行处理。


-------------------------
举例文件
链接:https://pan.baidu.com/s/1KnQNuuzueikPOkpAAh3-5Q?pwd=t4mp
提取码:t4mp
--来自百度网盘超级会员V9的分享


感谢。
发表于 2023-7-26 09:29:48 | 显示全部楼层
本帖最后由 77七 于 2023-7-26 09:46 编辑
  1. @echo off
  2. chcp 65001 >nul
  3. rem 批处理保存为utf-8编码格式,需要ffmpeg
  4. for /f "tokens=1* delims=_" %%a in ('dir /b /ad *_En') do (
  5.         pushd "%%a_%%b"
  6.         for /f "delims=" %%i in ('dir /b /a-d *.mp3') do (
  7.                 if exist "%~dp0%%a_Ch\%%i" (
  8.                         md "%~dp0%%a" 2>nul
  9.                         if not exist "%~dp0%%a\%%i" (
  10.                                 "%~dp0ffmpeg.exe" -i "concat:%%~fi|%~dp0%%a_Ch\%%i" -acodec copy "%~dp0%%a\%%i"
  11.                         )
  12.                 )
  13.         )
  14.         popd
  15. )
  16. pause
复制代码
 楼主| 发表于 2023-7-26 09:44:04 | 显示全部楼层
回复 2# 77七
谢谢

运行后有下面提示 怎么修改


    'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
发表于 2023-7-26 09:46:28 | 显示全部楼层
回复 3# qd2024


   已在2楼修改,重新复制。
 楼主| 发表于 2023-7-26 10:50:07 | 显示全部楼层
回复 4# 77七


    测试成功 谢谢
 楼主| 发表于 2023-7-26 20:41:57 | 显示全部楼层
回复 4# 77七


    有空吗 再帮忙看看这个能不能实现  
       http://www.bathome.net/viewthread.php?tid=66892&extra=


感谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 03:33 , Processed in 0.019969 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表