I hope you can help out here. I am not very experienced with either batch command files or Bash command files on MacOS (either very welcome).
I have thousands of video files in AVI format (DV recordings) which contain the recording date and time that an be retrieved using the MediaInfo tool. I would like to rename the files using the recording date info because I would like to re-encode them in a more efficient codec [H.265] thereby losing the meta-info inside the files. I thought the easiest way to keep the info is to store it in the file names. The file names are now with the date of the transfer from DV video to PC.
I found this article to be very helpful and based on that I have tried to make a version that works for me on the Windows command prompt. I can retrieve the correct info from MediaInfo but I can't get the batch file to execute properly. There is something wrong with the for loop, but I cannot figure it out. I trust somebody can help here.
@echo off & setlocal
cd C:\Users\dagsp\Desktop
for /f "delims=" %%i in ('dir /b /a-d *.avi') do (
set "fnameo=%%~ni"
set "fnamee=%%~xi"
set "RecDate="
for /f "delims=" %%j in ('mediainfo "--Inform=General;%%Recorded_Date%%" "%%~i"') do set "RecordingDate=%%j"
setlocal enabledelayedexpansion
call set "selftest=%%fnameo:[RecDate !RecDate!p]=%%"
if "!selftest!" equ "!fnameo!" if not exist "!fnameo! [RecDate !RecDate!p]!fnamee!" (
echo rename "!fnameo!!fnamee!" "!fnameo! [RecDate !RecDate!p]!fnamee!"
)
endlocal