我想运行一个月运行的批处理脚本。代码如下。它处理大量视频并将各种输出发送到各种文件夹。 问题是如果它无人值守运行一个月,磁盘可能已满。我希望它检查磁盘是否已满并继续写入另一个磁盘。有一个日志也很好
`@echo off
setlocal enabledelayedexpansion
set EXE_FILE=E:\opencv\build\bin\Release\blobtrack_sample.exe
set INPUT_PATH=E:\Glasgow\Test\
set TRACKS_PATH=E:\Glasgow\Tracks\
set OUTPUT_PATH=E:\Glasgow\Result\
set COUNT=0
pushd %INPUT_PATH%
for %%f in (*) do if %%f neq %~nx0 (
set /a COUNT+=1
echo Processing %%f, track=%%~nf.txt, btavi=test!COUNT!%%~xf
%EXE_FILE% fg=FG_0S bd=BD_CC bt=CCMSPF btpp=None bta=Kalman btgen=RawTracks track=%TRACKS_PATH%\%%~nf.txt FGTrainFrames=125 btavi=%OUTPUT_PATH%\%%~nf.avi %%f
)
popd`
答案 0 :(得分:0)
请考虑以下事项:
`@echo off
set drive="E"
set /A size=99
FOR /F "tokens=1-5" %G IN ('dir ^| find "Dir(s)"') do set size=%I
echo %size% > currentsize.txt
echo %size% >> sizelog.log
FOR /F "tokens=1-5" %G IN ('dir ^| find "currentsize.txt"') do set /A size=%J
REM SIZE LESS THAN 4 INDICATES LESS THAN 1024 Bytes left on the disk.
IF %size% LSS 4 set drive="F"
setlocal enabledelayedexpansion
set EXE_FILE=%drive%:\opencv\build\bin\Release\blobtrack_sample.exe
set INPUT_PATH=%drive%:\Glasgow\Test\
set TRACKS_PATH=%drive%:\Glasgow\Tracks\
set OUTPUT_PATH=%drive%:\Glasgow\Result\
set COUNT=0
pushd %INPUT_PATH%
for %%f in (*) do if %%f neq %~nx0 (
set /a COUNT+=1
echo Processing %%f, track=%%~nf.txt, btavi=test!COUNT!%%~xf
%EXE_FILE% fg=FG_0S bd=BD_CC bt=CCMSPF btpp=None bta=Kalman btgen=RawTracks track=%TRACKS_PATH%\%%~nf.txt FGTrainFrames=125 btavi=%OUTPUT_PATH%\%%~nf.avi %%f
)
popd`
答案 1 :(得分:0)
我从this answer找到了这段代码。我建议你阅读那里的所有答案,你会发现可以使用的东西
将后续文件保存在批处理文件中并运行它。它将显示C:驱动器的空闲字节。在IF条件中使用变量来更改目标保存到驱动器
@setlocal enableextensions enabledelayedexpansion
@echo off
for /f "tokens=3" %%a in ('dir c:\') do (
set bytesfree=%%a
)
set bytesfree=%bytesfree:,=%
echo %bytesfree%
endlocal && set bytesfree=%bytesfree%