AutoBaker
AutoBaker

Reputation: 1297

ffmpeg check if file exists before trying to process

I have this code to transcode a batch of videos to low res and add a watermark.

 %~d1
  CD "%~p1"
  MD "Proxy"
  attrib +h Proxy /s /d
    for %%a in ("*.MOV") do ffmpeg -i "%%a" -i "M:\Box Sync\Batch Processing\ffmpeg\proxy.png" -filter_complex "overlay=0:0" -q:v 20 -q:a 0  "Proxy/%%~na.mp4"
  attrib -h Proxy /s /d
PAUSE

How can I check to see if any output files already exist in \proxy\ and if so, to skip processing them?

Upvotes: 0

Views: 658

Answers (1)

GregHNZ
GregHNZ

Reputation: 8969

You should simply be able to precede the ffmpeg with if not exist <file>

https://ss64.com/nt/if.html

 %~d1
  CD "%~p1"
  MD "Proxy"
  attrib +h Proxy /s /d
    for %%a in ("*.MOV") do if not exist "Proxy/%%~na.mp4" ffmpeg -i "%%a" -i "M:\Box Sync\Batch Processing\ffmpeg\proxy.png" -filter_complex "overlay=0:0" -q:v 20 -q:a 0  "Proxy/%%~na.mp4"
  attrib -h Proxy /s /d
PAUSE

Upvotes: 2

Related Questions