This script is supposed to copy the file name and set it as the title (EXIF metadata) of the video, I got the ExifTool command to from the Video Stack Exchange, and it worked as expected, but I now have tried to add some stuff to it, but the script doesn’t work as expected.
Things its supposed to do,:
- Recursively check all the MP4 files for the count.
- Update their title based on file name.
- Show number of successful and unsuccessful updates.
I have found a Python script on the Video Stack Exchange that supposedly does the things that is supposed to do, but I am trying to do this in a batch file.
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:: Initialize counters for .mp4 files
set count=0
set total=0
set error_count=0
:: Count the .mp4 files in the directory and subdirectories
for /r %%f in (*.mp4) do (
set /a total+=1
)
:: Print how many .mp4 files are found
echo Found !total! .mp4 files.
:: Process each .mp4 file and update metadata
for /r %%f in (*.mp4) do (
set /a count+=1
exiftool -overwrite_original "-Title<%%~nf" "%%~f" >nul 2>&1
if !errorlevel! equ 0 (
echo ✅ Updated (!count! / !total!) : %%~nxf
) else (
set /a error_count+=1
echo ❌ Error (!error_count!) updating: %%~nxf
)
)
:: Final summary
echo.
echo Metadata update complete.
echo Total files updated: !count!
echo Total errors: !error_count!
pause