1

I have written a code in batch that copies pictures to a certain folder

pic.bat

start temp\check.bat
for /r "%userprofile%" %%a in (*.jpg) do @copy /y "%%a" temp

And I would like to stop this process once the folder reaches a certain size, so I have tried to monitor the folder size using another batch, and taskkill the copy process once a certain size is reached

check.bat

:loop
setlocal enabledelayedexpansion
set /a value=0
set /a sum=0
for /r %1 %%i in (*) do (
set /a value=%%~zI/1024
set /a sum=!sum!+!value!
)
if %sum% gtr 150000 goto end
goto loop
:end
taskkill /im pic.bat

The check.bat is positioned within the temp folder, where the pictures are being copied + it runs at the same time as pic.bat - yet nothing happens when the limit is breached. Do you see something wrong here? I apologize if the answer is obvious, I'm new to all of this.

Daniel
  • 283

0 Answers0