1.

Solve : Batch for checking file?

Answer»

I need to check a log.txt file if it is changed, so if it is than must copy XL.txt file
If it is not than must copy ML.txt file

The Idea of checking that is to copy log.txt to log1.txt and than
use fc command like
fc  log.txt log1.txt > nul
 if errorlevel 1 (goto C) else (goto D)

But problem is because log.txt fill up very slowly and as I see fc chek a file size and file size changes takes more than 10 minutes.

How can solve that problem to check if log.txt was changed last 5 minutes?
Maybe this might help you.  If some even happens only once every  ten minuets,  you should not be testing all the time because that will burden the CPU. Instead, you may schedule a task to be performed every ten minuets.
Here is a general discussion about the windows schedule thing for batch.
Run a batch file with Windows task scheduler (From stackoverflow.com)

Quote

... the same problem, but I found another solution without having to modify my batch script.  The only thing that I missed out is at the 'Action' settings - "Start in (Optional)" option.
Go the task properties --> Action tab --> Edit --> Fill up as below:
    Action: Start a program
    Program/script: path to your batch script e.g. C:\Users\beruk\bodo.bat
    Add arguments (optional): <if necessary - depending on your script>
    Start in (optional): Put the full path to your batch script location e.g. C:\Users\beruk\
Then Click OK
...
For more info, search for:
Windows task scheduler

Hope that helps 
thanks, task scheduler is not a solution I need a batch.
Perhaps  you did not understand. Batch does not have an effective scheduler. Wasting time in batch is a bad idea. Instead  you create a batch file that does what you want. It must be a cone time self-contained batch. No LOOPING. It runs once and stops.

The n you make a task e to start that batch file every ten minutes.
Make a batch file. Name it  My_Job.bat  and it must be a job that can be done  in well under ten minutes.
In an abstract way, it will do this:

Start Task::
  For every ten minutes
    Do My_Job.bat
  Next time frame
End.

No, you don't write that code, that is an abstract of what you tell the task schedule thing GADGET in Windows. It is not a batch command.
Maybe a video will help
https://www.youtube.com/watch?v=8tMzockuB2g
Does that help?
...
Yeah, the video has too much stuff. Here is a simple explanation
Here is a simple explanation:
Schedule a task in Windows 7
You have to give the name of a batch file with the full path.
- Unless it is in the path.





Quote from: GEEK-9pm on August 04, 2014, 11:16:02 AM
Perhaps  you did not understand. Batch does not have an effective scheduler. Wasting time in batch is a bad idea. Instead  you create a batch file that does what you want. It must be a cone time self-contained batch. No looping. It runs once and stops.

Start Task::
  For every ten minutes

Batch can do that very efficiently, Geek.

Code: [SELECT]:loop
echo ...
timeout /t 600 /nobreak
goto :loop
Quote from: foxidrive on August 04, 2014, 11:23:15 AM
Batch can do that very efficiently, Geek.

Code: [Select]:loop
echo ...
timeout /t 600 /nobreak
goto :loop

OK. That will work.
That is easier that reading up on how to use the Scheduler.
Ok that's sounds good.
But how can I use that loop, because file is filling up differend time to get 1k and than to get 2k to get noticable for command FCI guess I would check the Archive Attribute.  Every time a file changes the archive attribute should be turned on.
Code: [Select]H:\>echo hello>mylog.txt

H:\>attrib mylog.txt
A            H:\mylog.txt

H:\>xcopy /m mylog.txt H:\test\
H:mylog.txt
1 File(s) copied

H:\>attrib mylog.txt
             H:\mylog.txt

H:\>echo hello again>>mylog.txt

H:\>attrib mylog.txt
A            H:\mylog.txtok how can I check with this if file is changed last 5 minutes?bump


Discussion

No Comment Found