How to process files without string in filename?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joepyeweed
Posts: 1
Joined: 10 Jul 2017 19:58

How to process files without string in filename?

#1 Post by joepyeweed » 10 Jul 2017 20:12

I'm using ffmpeg to process a large number of videos in a large number of directories to re-encode to hevc. This part I can handle no problem. The problem is that in past I had already re-encoded some files and I want to skip them. There are two ways to do this. One is far above my abilities I think (reading the codec via ffmpeg and then deciding whether to process the re-encode) and the other should be fairly simple. The re-encoded files will have the string h265 at the end of the file name like videoname.h265.mp4. I've tried using the following code, but it isn't skipping files with the string h265 in them:

Code: Select all

for %%a in ("*.*") do findstr /v /c:"h265" "%%a" >nul && ffmpeg -hide_banner -i "%%a" -c:v libx265 -preset ultrafast -x265-params crf=23:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 -c:a copy "%%~na.h265.mp4"
pause


Any suggestions on getting this to work?

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: How to process files without string in filename?

#2 Post by penpen » 11 Jul 2017 05:46

This might help you:

Code: Select all

@echo off
setlocal enableExtensiuons disableDelayedExpansion
for %%a in (*.*) do for %%b in ("%%~na") do if /i not "%%~xb" == ".h265" (
   echo(Process file: "%%~a"
)
goto :eof


penpen

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: How to process files without string in filename?

#3 Post by Samir » 19 Jul 2017 06:33

If you know the output filename, you can use

Code: Select all

IF NOT EXIST path\file
to check if the file already exists before even running the ffmpeg part of the process.

I built an N-scaleable multi-computer network-based mp3 encoder batch file like that back in the day when real-time encoding was unheard of. Using about 3 computers, I could get real-time encoding speeds as each system would determine if the file encoding had been completed by looking for the encoded file (IF NOT EXIST XXX.MP3 L3ENC XXX.WAV XXX.MP3), and beyond 5 computers it would exceed real-time encoding. Too bad I never had 20 computers to test it on as I think I would have achieved some impressive speeds. (And now that I think about it, you probably could use the same methodology to make your transcoding project much faster if you have multiple computers available on a network since ffmpeg is stand-alone.)

catalinnc
Posts: 39
Joined: 12 Jan 2015 11:56

Re: How to process files without string in filename?

#4 Post by catalinnc » 20 Jul 2017 13:00

this will encode ONLY the files that are not already re-encoded to .h265.mp4...

put all the files in a "movies" subfolder...

Code: Select all

title %~nx0

@echo off & cls

setlocal disabledelayedexpansion

for /f "delims=" %%M in ('dir /a-d /s /b movies ^| find /v ".h265"') do (

if not exist "%%~dpnM.h265.mp4" (

ffmpeg.exe -hide_banner -i "%%M" -c:v libx265 -preset ultrafast -x265-params crf=23:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 -c:a copy "%%~dpnM.h265.mp4"

)

)

endlocal

pause

exit /b

_

Post Reply