We want to move ( not DELET ) log files after every 5 minutes form one location to another.
But also we do not want to move the log file which is currently active.
Means we want to move the logfiles which are 5 minutes older than System Date.
Can we get the Windows Script for the same, which we can use in the windows scheduler.
Hi Ami:
When you say "5 minutes older than system date", I assume you refere to file modification time ?
Here is the windows script in biterscripting.
# Script MoveLog5min.txt
var str source, destination, pattern
# Create a time string that represents "5 minutes earlier" (subtract 05 mins, 00 seconds from current time).
var str time
set $time = addtime(diff("-0500"))
# Collect a list of files matching $pattern in folder $source whose modification time is earlier than $time.
var str list, file
lf -n $pattern $source ( ($ftype=="f") AND ($fmtime < $time) ) > $list
# Go thru files one by one.
while ($list <> "")
do
# Get the next file.
lex "1" $list > $file
# Move file to $destination.
system -s ("move /Y \""+$file+"\" \""+$destination+"\"")
done
Save the script in file "C:/Scripts/MoveLog5min.txt", start biterscripting, enter the following command.
script "C:/Scripts/MoveLog5min.txt" source("C:/Log Directory") destination("C:/Moved Log Directory") pattern("*.log")
This will move all files matching name "*.log" which have not been modified in the last 5 minutes from source folder "C:/Log Directory" to destination folder "C:/Moved Log Directory" .
Test it first. When all working, schedule the following command in task scheduler.
"C:/biterscripting/biterscripting.exe" "C:/Scripts/MoveLog5min.txt" source("C:/Log Directory") destination("C:/Moved Log Directory") pattern("*.log")
(Just replace the command word 'script' to the path of biterscripting executable.)
Do let me know how this works out for you.