Alston
Alston

Reputation: 2137

How to convert audio in each directory by FFmpeg and batch script.

After a hard study, I have created a batch file:

for /R  D:\storytelling\MusicFiles %%a in (*.3gp) do ffmpeg -i %%a -y %%~na.mp3

However, it can't reach my goal since the scenario is a little different here:

Here is my directory structure: enter image description here

I have several directories under a certain path:D:\storytelling\MusicFiles\ and new directories could be created by another application. And I put ffmpeg.exe file in this path: D:\storytelling\MusicFiles\.
Also, In each directory, I have hundreds of .3gp files, and my target is to convert them to .mp3 in the directory where they used to stay at.
But this script

for /R  D:\storytelling\MusicFiles %%a in (*.3gp) do ffmpeg -i %%a -y %%~na.mp3

would convert every .3gp file in each directory to the path: D:\storytelling\MusicFiles\

It leads to:enter image description here
But I want the publicUser_XXX.mp3 files are still in the directory publicUser and after conversion all the files remain in their original directory. The only change is that I got new a media copy with different media format like: enter image description here

Please help and give me some advise.

Upvotes: 2

Views: 1823

Answers (1)

foxidrive
foxidrive

Reputation: 41267

Try this:

@echo off
for /R  D:\storytelling\MusicFiles %%a in (*.3gp) do ffmpeg -i "%%a" -y "%%~dpna.mp3"

Upvotes: 2

Related Questions