Here is an excerpt of a long ffmpeg script I have and I have it:
- Creating a text file of the video files in the current directory
- With a FOR statement searching through the text file
- Outputting to a subdir
What I want to add in is to not only not "process" go through the rest of the script if the file already exists but also not to process that ALREADY existing file. (In other words: If a copy of the file already exists in an output directory skip processing the file, but also to skip processing the duplicate file itself that was identified.)
dir *.mkv *.mp4 /A-D-H /B /S |findstr /R %Exclude-Final% /v /i>%TempFilePath%
Echo: These are the folders being Excluded: "!Exclude-AlltheseFolders!"
SET "FINALCOMMAND="
::******** DON'T EDIT-----Keeping Original Audio**************END END***************
SETlocal EnableExtensions DisableDelayedExpansion
SET "FilesFound=0" & SET "FilesEncoded=0" & SET "output="
for /F "delims=" %%I in (%TempFilePath%) do (
::ECHO ==!TIME!================Next File: %%I ========================
SET "output=%drive%%%~pI%%~nxI" & SET "filename=%%~nxI" & SET /A FilesFound =1
SETlocal EnableExtensions EnableDelayedExpansion
IF exist "%drive%%%~pIoutput\%%~nxI" (SET "Convert_Audio1=N") ELSE IF !output2! == 1 (SET "Convert_Audio1=N") ELSE SET "Convert_Audio1=Y"
rem ===============================
rem FFProbe.exe evaluation of %%I files
rem ===============================
rem below still under the FOR statement above: for /F "delims=" %%I in (%TempFilePath%) do (
rem ------------------------------------------------------------
rem -----------------------------
IF !ConvertCodecs! == 1 (
SET /A count=5
IF /I "!output!" == "%%I" (
SET "output=%~dp0output\!filename!"
rem ECHO This is OUTPUT-DIR "%~dp0output\"
MKDIR "%~dp0output\"
) ELSE (
MKDIR "%drive%%%~pI"
)
ENDLOCAL
......
ENDLOCAL
ENDLOCAL
ENDLOCAL
```
I want filtration to all occur here, before it goes through the FFProbe.exe processing to speed it up. I assume in the 1st IF statement there is something I can do, but when there are multiple files, or even just 2 1 sub-folder, it can not carry-over the right variable i.e. this will skip file1, process file 2, and then try to process file3
EDIT: Here is the Full Code. You will need to input what you want the destination drive to be (i.e. C: or D: etc...). It will look for mkv's and mp4's that have eac3,flac,dts,pcm,aac,or ac3 to convert to aac. ( Batch Convert Videos audio from one format to another )
@ECHO OFF
SETlocal
SET drive="~dp0"
SET string=