Skip to content

Instantly share code, notes, and snippets.

@BrunoReX
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoReX/6eb38bd27f0ec83bb348 to your computer and use it in GitHub Desktop.
Save BrunoReX/6eb38bd27f0ec83bb348 to your computer and use it in GitHub Desktop.
Prints file name and bitrate from video files inside of the current folder
@echo off
Setlocal EnableDelayedExpansion
REM Path to ffprobe executable, not needed if already in PATH
set FFPROBE_EXE=ffprobe
REM Cleanup
del /f /q bitrates.txt
REM Add or remove extensions if needed
for /r %%a in (*.mp4;*.mpg;*.mpeg) do (
REM Prints the full path of the file into text file (change %%~fa to %%~nxa to print file name plus extension)
echo %%~fa>>bitrates.txt
REM Get line that contains bitrate in ffprobe's output (e.g. " Duration: 00:27:00.03, start: 0.000000, bitrate: 1568 kb/s")
REM Print it to a temp file
"%FFPROBE_EXE%" "%%~a" 2>&1 | findstr bitrate>tmpFile
REM Read temp file into a variable
set /p bitrate= < tmpFile
REM Cleanup
del /f /q tmpFile
REM Get only the birtate portion of the output (e.g. " bitrate: 1568 kb/s")
for /f "tokens=3 delims=," %%b in ("!bitrate!") do set bitrate2=%%b
REM Remove trailing space (e.g. "bitrate: 1568 kb/s")
for /f "tokens=*" %%c in ("!bitrate2!") do set bitrate=%%c
REM Print it into the text file after the file name
echo !bitrate!>>bitrates.txt
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment