The following windows script will move files older than a given date from C: folder1 to C: folder2. By older, I am assuming that they are not modified after a certain date.

Scenario: One of the post I wrote 'How to delete old files' that you can check Here. In this post we will be deleting the old folders. We will be able to provide the Retention Period in Days. The package will delete all the old Folders older than Retention period in days.

The date is passed in the format yyyymmdd. When files are moved to folder2, they are automatically deleted from folder1. # Script movefiles.txt # Input argument - date var str date # Get a list of files not modified since $date. Var str list; lf -n '*' 'C: folder1' ( ($ftype == 'f') AND ($fmtime $list # Move files one by one. While ($list ') do var str file; lex '1' $list >$file system move $file 'C: folder2' done The script is in biterscripting. Download biterscripting from. Save the script as C: Scripts movefiles.txt.

Delete Files Older Than Linux

Start biterscripting. Call the script as script movefiles.txt date('20090613') The above will move files that have not been modified since June 13, 2009 (30 days before today). Email Id removed for security said: >We generate about 1000 reports per hour on our webserver and >run a nightly script to remove these files. Unfortunately, that is not often enough >and need to have a script that we can run every hour >that removes old files (older than say 1 hr). >Can someone steer me to a solution that uses the system time, >and removes files from our 'reports' directory that are older? Thx in Advance This script will do exactly what you need.

I will assume that these report files are in folder 'C:/hourly reports'. I am adding comments so you can follow the logic. # Script HourlyDelete.txt # Go to reports folder. Cd 'C:/hourly reports' # Collect a list of files that were CREATED more than an hour ago. Var str list, file lf -r -n '*' '.' ( $fctime $list # Delete each file in $list one by one. While ($list ') do lex '1' $list >$file echo -e 'DEBUG: Deleting file ' $file system del (' '+$file+' ') done Script is in biterscripting.

Test it first on a test folder. Change 'C:/hourly reports' in the script to correct path. Double quotes are required around paths. To test, save the script in file C:/Scripts/HourlyDelete.txt, then enter the following command in biterscripting. Adam Equity Theory Of Motivation Pdf.

Script 'C:/Scripts/HourlyDelete.txt' Once you know it's working, schedule the following command in task scheduler to run hourly. 'C:/biterScripting/biterScripting. Black Ops Product Key Generator. exe' 'C:/Scripts/HourlyDelete.txt'. 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 $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.

Coments are closed
Scroll to top