Hi Guys....
Need help!
Using "Task Scheduler" in windows7 32bit is it possible to run a batch file to delete a file 10 seconds after it is made by another program? The batch file would be using windows "forfiles.exe" so I am guessing the start of the batch file would look like
forfiles /p "C:\testfolder\" /s /m zm_model.inf
If this method isn't possible, is there any other way that one file ( zm_model.inf ) be deleted automatically 10 seconds after it is made.
Thanks!
Val
Batch file to delete 1 file 10 secs after it appears?
Moderator: DosItHelp
Re: Batch file to delete 1 file 10 secs after it appears?
Just use FOR /R to find a file and set an environmental variable. Then do an IF DEFINED variable with a timeout and a delete.
Re: Batch file to delete 1 file 10 secs after it appears?
Squashman....
Thanks....but I just figured it out a few mins before I checked back here.
@echo off
:start
cls
If exist zm_model.inf goto delete
if not exist zm_model.inf goto wait
:delete
color 0a
echo.
echo.
echo.
echo DELETED zm_model.inf EXISTING FILE
echo PRESS ctrl + c TO EXIT THIS LOOPING BATCH FILE
echo.
echo OR LEAVE IT RUNNING IF YOU STILL REQUIRE IT
echo TO DELETE MORE GENERATED zm_model.inf FILES
del zm_model.inf
PING 1.1.1.1 -n 1 -w 10000 >NUL
cls
goto start
:wait
color a0
echo.
echo.
echo.
echo WAITING FOR THE NEXT zm_model.inf TO BE GENERATED
PING 1.1.1.1 -n 1 -w 10000 >NUL
goto start
echo.
echo.
echo.
I just leave this batch running until I am done.
Thanks again!
Val
Thanks....but I just figured it out a few mins before I checked back here.
@echo off
:start
cls
If exist zm_model.inf goto delete
if not exist zm_model.inf goto wait
:delete
color 0a
echo.
echo.
echo.
echo DELETED zm_model.inf EXISTING FILE
echo PRESS ctrl + c TO EXIT THIS LOOPING BATCH FILE
echo.
echo OR LEAVE IT RUNNING IF YOU STILL REQUIRE IT
echo TO DELETE MORE GENERATED zm_model.inf FILES
del zm_model.inf
PING 1.1.1.1 -n 1 -w 10000 >NUL
cls
goto start
:wait
color a0
echo.
echo.
echo.
echo WAITING FOR THE NEXT zm_model.inf TO BE GENERATED
PING 1.1.1.1 -n 1 -w 10000 >NUL
goto start
echo.
echo.
echo.
I just leave this batch running until I am done.
Thanks again!
Val