Looking for a way execute a task on all files in a directory (recursively) on Windows

I have a huge number of mp4 video files that needs to have a volume boost. I need a way to execute a ffmpeg audio filter on all files in a specified base directory (and in subdirectories as well). My problem is that I'm working on a Windows computer and I have no knowledge of its shell syntax.

I would like to do the equivalent of what this bash script does :

TARGET_FILES=$(find /path/to/dir -type f -name *.mp4)
for f in $TARGET_FILES
do
  ffmpeg -i $f -af 'volume=4.0' output.$f
done

I spent quite some time this afternoon looking for a solution but the recursive nature of what I need (that is so simple with find!) isn't too clear.

Any help would be greatly appreciated!


Solution 1:

In short, your script translates to the command-prompt one-liner:

for /r "C:\path\to\file" %f in (*.mp4) do ffmpeg -i %f -af 'volume=4.0' output.%f

Explained: for command loops over all files that meet certain criteria and execute command after do. /r means recursive (i.e. search into subfolders); %f is arbitrary variable similar to $f in your script. Other parts should be self-explanatory.

Solution 2:

Stack Overflow has a similar PowerShell script for using ffmpeg and recursing through folders, but was for changing the type of file.

Someone correct me if I'm wrong (I don't know ffmpeg) but taking that article and your command would give something like this in PowerShell:

$oldvids = Get-ChildItem *.mp4 -Recurse
foreach ($oldvid in $oldvids) {
     .\ffmpeg.exe -i $oldvid.FullName -af 'volume=4.0' $oldvid
}

You'll need to have PowerShell installed on your system, which is built-in to Windows 8, but available for download for previous versions of Windows as part of the Windows Management Framework