As part of my Batch file logging I keep 2 files as accumulative error logs, one is for INTERNET related errors, and the Other is for COMPUTER related errors. My recent batch for rebooting the router works very well, however I decided that rather than getting into a LOOP situation if the error was external to my network such as due to my INTERNET Service Provider who is coming to fix a problem with my phone line on Wednesday. I created 2 logs, which are written to depending on the fault, PC v NET, actions are taken depending on the type of error, if after 3 tries the error is not fixed the server is shut down.
However if after a few days their are no errors I want to zero them out, or delete them if older than 7 days. I like what I read about FORFILES and I downloaded forfiles.exe but it will not work on my windows XP SP3 system perhaps it has some missing DLL files ? My STATUS error log compare files are.
ustable.txt and wanout.txtHere is my command line in test mode:
FORFILES -p"C:\State" -m*ust*.txt -d"-7" -c "cmd -c del @FILE"
forfiles -p"C:\State" -m*nout.txt -d"-7" -c "cmd -c del @FILE"I tried all sorts of variations most just do not do anything, not even an error so I’m baffled ?
If I get the format on the line wrong I do get the HELP list from forfiles however but just no functionality of the purpose of forfiles. Need a simple solution.Michelle
PS I finally got it working lol the format was very confusing found some tips online this works for me.
forfiles.exe -p"C:\State" -m*.txt -d-7 -c"cmd /c del /q @FILE"
Not even in English but the code was :p
http://batch.xoo.it/t3436-Programma...If Dreams Come True Oleg Would be Famous so far he's very shy, so much for Being Famous ;) http://www.book-stores.com/angels-
message edited by Ortorea
Try this: @echo off
setlocal
set "days=7"
set "tnow=%~2"
call:ftime tfile "%~1"
set /a "diff=tnow-tfile"
if %diff% LEQ %days% EXIT /b
set "attr=%~a1"
rem ECHO.%attr%, %attr:~0,1%, %~nx1 is %diff% days old
if /i "%attr:~0,1%"=="d" (
rd /Q /S "%~1"
) ELSE (
del /Q "%~1"
)
EXIT /bUsage: <name>.bat [file/directory] [date]
Dear thephantomblu Thank you so much for your neat code I will use that :)
Michelle xoxox
If Dreams Come True Oleg Would be Famous so far he's very shy, so much for Being Famous ;) http://www.book-stores.com/angels-
message edited by Ortorea
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |