@echo off setlocal EnableDelayedExpansion :: --- Configuration --- set "directory=_cleaned" set "ffmpeg_options=" :: Create the target directory if not exist "%directory%" mkdir "%directory%" echo Starting metadata removal in: %CD% :: Loop through all files in the current directory for %%F in (*) do ( :: Skip if it's a directory if exist "%%F\" goto :continue :: Skip the script itself (clean_metadata.bat) if /i "%%F"=="%~nx0" goto :continue :: Skip files that already have "_clean" suffix :: We check if the name (%%~nF) ends with "_clean" set "fname=%%~nF" if "!fname:~-6!"=="_clean" goto :continue :: Construct output filename: name_clean.extension set "output_file=%%~nF_clean%%~xF" echo Cleaning: %%F → !output_file! :: Remove metadata: -map_metadata -1 removes all, -c copy avoids re-encoding ffmpeg -loglevel quiet -i "%%F" -map_metadata -1 -c copy %ffmpeg_options% "%directory%\!output_file!" if %errorlevel% equ 0 ( echo Done: !output_file! ) else ( echo Error: Failed to clean %%F ) :continue ) echo All done. pause