Hi Am actually trying to redirect the output of a for loop to a file in batch and I don't want to create a empty file if there is no output from the for loop.
In the below code, I am trying to redirect the name and date modified of files in a particular directory which are more than 60 mins old to a file called Errorfiles.txt. If there are no files that were modified in the last 60 mins then I should not get a empty file but am getting a file of 0KB size. Is there anyway I can stop generating that file if there's no output from the for loop ?
Any help would be appreciated Thanks!
-----------------------------------------------------------MAIN.bat-----------------------------------------------------------
    @Echo off
    @setlocal EnableDelayedExpansion
    CALL function.bat %TIME%,CurrentTime
    (for /f "tokens=2,4" %%A in ('dir c:\Users\Administrator
    \Batch\*.* ^| find "/"') do (
    CALL function.bat %%A,FileTime
    REM echo !CurrentTime! !FileTime!
    set /a diff=!CurrentTime!-!FileTime!  
    if !diff! geq 60 (
    echo Filename: %%B Date Modified %%A 
    )
    )) 1>ErrorFiles.txt 2>nul
-------------------------------------------------------------------Function.bat--------------------------------------------
    @Echo off
    SET time1=%1
    set HH=%time1:~0,2%
    set MM=%time1:~3,2%
    set /a MM=%MM%
    set /a HH=%HH% * 60
    set /a ctime=%HH% + %MM%
    set /a "%~2=%ctime%"
    EXIT /B      
 
     
     
    