@echo off REM References: REM http://www.labnol.org/internet/useful-ffmpeg-commands/28490/ REM https://trac.ffmpeg.org/wiki/Concatenate REM http://www.dostips.com/ REM https://trac.ffmpeg.org/wiki/FFprobeTips REM https://gist.github.com/rbrooks/2829908 REM http://ffmpeg.zeranoe.com/builds/ SETLOCAL EnableExtensions EnableDelayedExpansion REM change to directory of dragged files pushd "%~dp1" REM Include any paths needed for external programs set path="F:\Utilities\commandlinetools\ffmpeg\bin";%path% if exist metadata_*.txt del metadata_*.txt if exist json_*.txt del json_*.txt REM empty confiles.txt if exist confiles.txt break>confiles.txt REM ffmpeg_tasks.bat REM Use FFmpeg/FFprobe for various tasks. Drag and drop files onto this file. REM Metadata saved to metadata_filename.txt file(s). All prior created metadata REM and json files deleted when script is launched. REM ---------------------- Version History ------------------------------------ REM Add new line for updated versions, keep previous for record REM Ver XX.XXX YYYY-MM-DD Author Description SET version=01.000 2015-10-28 cects.com initial version rem SET version=01.001 2015-xx-xx cects.com new stuff here REM -------------------------- Set title -------------------------------------- REM note: "%~nx0" = filename of the batch file SET title=%~nx0 - version %version% TITLE %title% REM ----------------------------- Program Code -------------------------------- echo Current working directory (%%CD%%): %CD% echo Directory of this script (%%~dp0): %~dp0 :main goto begin REM check to see if this file was executed without dragging a file to it :begin if [%1]==[] ( echo. echo "no files dragged to this file. Try again." echo. echo "press any key to exit ...." echo. pause >nul goto end ) else ( goto next1 ) :next1 call:theorder %* :menu echo ------------------------- FFmpeg/FFprobe Menu --------------------------- echo 01. Concatenate Dragged and Dropped Files (no encoding) to filename1_merged.ext echo 02. FFprobe write format/stream info to json_format_streams_pretty_filename.txt echo 03. FFprobe format/stream info to screen (single column format) echo 04. FFprobe basic file(s) info to screen (no options) echo 05. FFmpeg list Metadata of file(s) to screen echo 06. FFmpeg write Metadata of file(s) to metadata_filename.txt echo 07. Exit echo. SET PROFILE= set /P PROFILE=Enter your selection (0-7): if "!PROFILE!"=="1" goto confiles if "!PROFILE!"=="2" call:writejson %* && goto main if "!PROFILE!"=="3" call:listbasic %* && goto main if "!PROFILE!"=="4" call:listinfo %* && goto main if "!PROFILE!"=="5" call:listmeta %* && goto main if "!PROFILE!"=="6" call:writemeta %* && goto main if "!PROFILE!"=="7" goto end echo. echo "You must select a valid choice^! Try again^!" cls echo. goto menu echo. goto done REM Open log in Explorer (can open documents or directories) REM start %SystemRoot%\explorer.exe %logfilename% REM ----------------------------- Program Code End ---------------------------- :done echo. echo "Files joined successfully" echo. echo. call:errorfunc echo. REM Note: Endlocal causes Title to not display on exit, but REM countdown will display Endlocal REM ---------------------------- Delayed Exit -------------------------------- REM Sets exit code to 0 echo exiting in 15 seconds..........&echo. echo hit PAUSE on keyboard to pause... any key will resume exit FOR /l %%a in (15,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL) Title Press any key to exit . . .&echo.&EXIT /B 0 REM --------------------- Function Section ----------------------------------- :errorfunc echo The exit error code is: %ERRORLEVEL% goto :eof :theorder echo. echo Files will be processed in this order: echo. for %%z in (%*) do ( echo %%z ) echo. goto :eof :writejson echo. echo Write file info (ffprobe) json format: echo. for %%z in (%*) do ( REM Print json file in human readable format ffprobe -show_streams -show_format -pretty -print_format json %%~nxz >json_format_streams_pretty%%~nz.txt REM Uncomment to use below options REM ffprobe -show_format -print_format json %%~nxz >json_format%%~nz.txt REM ffprobe -show_streams -print_format json %%~nxz >json_streams%%~nz.txt REM ffprobe -show_streams -show_format -print_format json %%~nxz >json_format_streams%%~nz.txt ) echo. echo Press any key to return to menu ... pause >nul goto :eof :listbasic echo. echo Basic file Info (ffprobe) - suppress banner info: echo. for %%z in (%*) do ( ffprobe -hide_banner -v error -show_format -show_streams %%~nxz ) echo. echo Press any key to return to menu ... pause >nul goto :eof :listinfo echo. echo File Info (ffprobe) - suppress banner info: echo. for %%z in (%*) do ( ffprobe -hide_banner %%~nxz ) echo. echo Press any key to return to menu ... pause >nul goto :eof :listmeta echo. echo List file metadata (ffmpeg) - suppress banner info: echo. for %%z in (%*) do ( ffmpeg -hide_banner -i %%~nxz -f ffmetadata ) echo. echo Press any key to return to menu ... pause >nul goto :eof :writemeta echo. echo Write metadata (ffmpeg) to files: echo. for %%y in (%*) do ( ffmpeg -i "%%~nxy" -f ffmetadata "metadata_%%~ny.txt" ) echo. rem echo Press any key to continue .... rem pause >nul goto :eof :confiles REM Save metadata to metadata_filename.txt echo. echo Saving metadata ... echo. for %%z in (%*) do ( ffmpeg -i %%~nxz -f ffmetadata metadata_%%~nz.txt ) REM get name and extension of 1st file, copy filenames to confiles.txt which REM is used to join files set namec=%~n1 set extnamec=%~x1 for %%z in (%*) do ( echo file '%%~nxz' >>confiles.txt ) echo metadata saved, files copied to confiles.txt REM If file is an mp3, then write id3 tags, else just write global metadata if %~x1 EQU .mp3 ( ffmpeg -f concat -i confiles.txt -i metadata_%~n1.txt -map_metadata 1 -id3v2_version 3 -write_id3v1 1 -c copy !namec!_merged%extnamec% ) else ( ffmpeg -f concat -i confiles.txt -i metadata_%~n1.txt -map_metadata 1 -c copy !namec!_merged%extnamec% ) echo. echo Files joined. Merged file is: "!namec!_merged%extnamec%" echo. echo Exiting ... echo. goto done REM --------------------------- exit now -------------------------------------- :end EXIT