printing - Having a Batch script print network contents in small files -
i have script prints contents on network local text files. need adjust script, each output file maximum 10 mb large.
so far script looks this:
::@echo off echo %date% %time% starting %~dp0 set year=%date:~-4% set month=%date:~3,2% set day=%date:~0,2% set hour=%time:~0,2% set minute=%time:~3,2% set second=%time:~6,2% set foldername=%year%-%month%-%day%-%hour%-%minute%-%second% set foldername=%foldername: =% set logger="%~dp0"\%foldername%.log ::loop igjennom alle folders på nettverket, alfabetisk. print ut innholdet hver mappe, med full path. set "list=n:\ o:\ p:\ r:\ v:\ y:\ z:\" %%i in (%list%) ( set project=%%i & call :project ) :project echo printing %project% >> %logger% set year=%date:~-4% set month=%date:~3,2% set day=%date:~0,2% set hour=%time:~0,2% set minute=%time:~3,2% set second=%time:~6,2% set foldername=%year%-%month%-%day%-%hour%-%minute%-%second% set foldername=%foldername: =% set logger="%~dp0"\%foldername%.log dir /b /a-d /s %project% > %logger%
the best file size check prior every folder print, this:
:folder echo printing %folder% >> %logger% if (logfilesize > 10mb) logfile=new logfile. print folder logfile.
i don't know how write in batch. how adjust script run :folder prior printing folder?
you can filesize for
. numbers may bigger cmd
can use them numbers, have use string comparison instead.
for %%i in (%logger%) set "size=0000000000%%~zi" set size=%size:~-10% if %size% gtr 0010485760 echo more 10mb
obviously, should compare number less 10mb, if want add still stay below 10mb (how less depends on data)
Comments
Post a Comment