Friends
I have a for loop where i loop through a dir full of video files - call an ffmpeg cmd and make mp4
I do that like so ( a snippit )
or /f %%a IN ('dir /b *.*') do
now this does my command on every file in that dir ( that i have already cd'd to )
it will work nicely on iether f.avi or f.mov ..... good
but it will *also* try to make a mp4 from a txt file ....which is not good
here is my question can i limit it to 2 declared extentions
like
or /f %%a IN ('dir /b *.avi OR *.mov') do
meaning it works on all file.avi all file.mov but ONLY those 2
so far I have solved this by 2 for loops
1 for *.mov and 1 for *.avi
thanks
jS
in a for loop just 2 kind of extentions
Moderator: DosItHelp
Re: in a for loop just 2 kind of extentions
You were close.
You can do this two ways.
or
You can do this two ways.
Code: Select all
FOR %%G IN (*.avi *.mov) do .....
Code: Select all
FOR /F "delims=" %%G IN ('dir /a-d /b *.avi *.mov') do....
Re: in a for loop just 2 kind of extentions
ok thanks but now I have this problem
my ffmpeg cmd was this
ffmpeg.exe -i %%a -y -vcodec libx264 -b:v 4110000 -pix_fmt yuv420p -g 12 -bf 3 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -s 1280x720 -acodec aac -strict -2 -ar 48000 -b:a 128k %destDir%\%%~na.mp
so when i did
or /f %%a IN ('dir /b *.*') do
and had dog.mov i would end with dog.mp4
now with
FOR %%G IN (*.avi *.mov) do
what do i do for the " %%~na.mp4 "
because now if i have 3 mov ...it overwrites and leaves the last as actually %%~na.mp4
i tried %%~ng.mp4 and i get a file actually named %%~ng.mp4
thanks
my ffmpeg cmd was this
ffmpeg.exe -i %%a -y -vcodec libx264 -b:v 4110000 -pix_fmt yuv420p -g 12 -bf 3 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -s 1280x720 -acodec aac -strict -2 -ar 48000 -b:a 128k %destDir%\%%~na.mp
so when i did
or /f %%a IN ('dir /b *.*') do
and had dog.mov i would end with dog.mp4
now with
FOR %%G IN (*.avi *.mov) do
what do i do for the " %%~na.mp4 "
because now if i have 3 mov ...it overwrites and leaves the last as actually %%~na.mp4
i tried %%~ng.mp4 and i get a file actually named %%~ng.mp4
thanks
Re: in a for loop just 2 kind of extentions
I always use an UPPERCASE G for my FOR variable. The FOR variable is case sensitive. It also helps with visually identifying which letters are the command modifiers and which one is the FOR variable.
Re: in a for loop just 2 kind of extentions
ummmph
yes
%%~nG.mp4
works nicely
thanks again!
yes
%%~nG.mp4
works nicely
thanks again!