I am about to start a project and need to do some analysis work before starting. Basically what i need to do is to create a batch file that will check a folder that has multiple files coming in and out of it (downloading/uploading), it will be run every minute for 24 hours and will create a .txt file with each of the files in the folder size. I am not expecting any of the files to be any larger than 2meg.
Over the 24 hour period i need to have multiple logs with every files size logged. I am looking for a minimum file size that comes into this folder.
I have created a script that at the moment creates a time stamped .txt that has the amount of files in the folder (this is not required within the .txt as it is in the file name)
Code: Select all
@ECHO OFF
SETLOCAL
SETLOCAL ENABLEDELAYEDEXPANSION
set site=Tnton
set gn=NH
:: Create date and timestamp for email
for /f "tokens=1-8 delims=.:/-, " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do (
for /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do (
set dow=%%i
set mm=%%j
set dd=%%i
set yy=%%k
set hh=%%l
set min=%%m
set sec=%%o
set hsec=%%p
)
)
:: ensure that hour is always 2 digits
if %hh%==0 set hh=00
if %hh%==1 set hh=01
if %hh%==2 set hh=02
if %hh%==3 set hh=03
if %hh%==4 set hh=04
if %hh%==5 set hh=05
if %hh%==6 set hh=06
if %hh%==7 set hh=07
if %hh%==8 set hh=08
if %hh%==9 set hh=09
:: Assign timeStamp
:: Add the date and time parameters as necessary - " yy-mm-dd-dow-min-sec-hsec "
set timeStamp=%yy%%mm%%dd%_%hh%-%min%
SET count=0
for %%o IN (C:\\*.txt) DO (
echo %%o
SET /A count=count + 1
)
:: Create filename
set fn=%count%--FileLogs--%site%-%gn%-%timestamp%.txt
echo %count% >> %fn%
ENDLOCAL ENABLEDELAYEDEXPANSION
ENDLOCAL
pause > nul