new here and hoping this is an easy question. I have very little background in programming and scripting but I've got the basics working so far and I'm stuck.
The logic of what I'm trying to accomplish with the parts marked I need help with;
- scan my IP cam folder for the largest file
- need help check that file against a list of already processed files
- move that file to a temp Working dir on a PC with a good CPU and SSD
- run HandBrake on it to compress it
- move the finished file back to its original location
- delete the original from the temp working directory
- write its file name to Processed.txt
- need help Loop the whole thing to run endlessly
Right now it's working perfectly to scan and find the largest file and send it for processing and move it back. What I want to add is a check of the Processed.txt file during the size scan as very often the largest files still end up to be the largest even after compression (so it gets stuck on the same one). Basically I want to be able to endlessly scan for the largest unprocessed file and compress them one by one. (I have THOUSANDS so typical batch processing wont really work)
I was trying to work out how to get the findstr into the for\do loop but I'm totally lost on that. My thinking is to take the current %name% variable, run it though findstr on the Processed.txt file and if it matches move on, if not make that the current largest file.
here's what I have working so far that I've managed to piece together from other posts;
SETLOCAL EnableDelayedExpansion
set tes=0
set name=
set path=
for /r D:\Cameras %%h in (*.*) do (
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
SET ext=%%~xh
)
)
move "d:%path%%name%%ext%" "d:\Working\"
HandBrakeCLI -i "d:\Working\%name%%ext%" -o "c:\Completed\%name%.mp4" -O -e x264 -q 23 -B 128 -w 720 -l 480 --auto-anamorphic
move "c:\Completed\%name%.mp4" "d:%path%%name%.mp4"
del "d:\Working\%name%%ext%"
echo !name! >> Processed.txt
Thanks in advance, and any and all help is greatly appreciated.
*****EDIT UPDATE***** So i couldn't get the below to work but it took me a new direction. Right now the below seems to be pretty close to working but the second FOR DO IF seems to process outside of the main loop. Maybe someone could help fix that because that is the logic that i think will work for me.
i rem out the stuff i know is working just to test if itll scan, enter the file name, then skip it next time around for testing.
rem :start
SETLOCAL EnableDelayedExpansion
set tes=0
set name=
set path=
set found=false
for /r d:\Cameras %%h in (*.*) do (
rem CALL :checkprocessed %%h
for /f %%x in (d:\Processed.txt) do (
IF "%%~nh" NEQ "%%~x" IF !tes! LSS %%~zh (
echo !tes! %%~zh %found% >> ifcheck.txt
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
SET ext=%%~xh
)
)
)
rem move "d:%path%%name%%ext%" "d:\Working\"
rem HandBrakeCLI -i "d:\Working\%name%%ext%" -o "c:\Completed\%name%.mp4" -O -e x264 -q 23 -B 128 -w 720 -l 480 --auto-anamorphic
rem move "c:\Completed\%name%.mp4" "d:%path%%name%.mp4"
rem del "d:\Working\%name%%ext%"
echo !name! >> Processed.txt
rem goto :start
rem :checkprocessed
rem SET found=false
rem for /f %%x in (d:\Processed.txt) do IF "%%~nh" EQU "%%~x" (SET found=true & echo !found! >> found.txt & exit /b 0)
rem exit /b 0