> the protogenLabs notebook » reading full entry…
13
Move old IIS logs or any files using this handy script!
» posted 1514 days ago @ 03:11 PM by George Merlocco in technology
> Leave a comment? [5] article comments…
Used the log script you had here… worked perfect! Thank You.
by Elton on 02.24.2011 @ 07:25 PM » #
hi
what command to issue when creating an empty log file after rotation? what is the /rn value?
by Candy on 09.08.2011 @ 03:10 AM » #
Sir,
I have downloaded this file.After that how to delete the files.
My OS is Windows server 2003
Requirement is
1.I want to move log files from 1 folder to another folder
2.before moving the file,the file has to be archived and then moved
3.After movement,the file in the source location should be deleted.
Please help me on this.
Thanks.
Sandeep
by Sandeep on 12.17.2011 @ 11:04 PM » #





Over the many years that I have been administering Windows Servers, one of the most forgotten and cumbersome tasks is to properly manage the log files that servers generate. Hosting websites and other services often generate many .log files which can grow to immense sizes. Recently this had happened to me, and I was looking for a method/script to run through a directory I point it to, and move all log files older than a certain date to my other partition.
After a bit of hunting around on the net, I eventually came across this GREAT script that uses the Windows Script Host to do exactly what I wanted. The script was developed by pforret, and is available for download at the end of this post. The current version of WaRmZip.wsf is v1.7. Below is a listing of a few functions that it is capable of:
waRmZip.wsf v1.7 (Nov 2005)
Utility to clean up/free up space in a folder (and its subfolders):
As an example, here is the command I typed to move all files older than 30 days into my LogFileArchive folder on D:
cscript waRmZip.wsf "C:\Windows\System32\LogFiles" /r /ma:30 /md:"D:\LogFileArchive\$YEAR\$COMP\IIS"waRmZip Readme (click to show/hide)
Usage:
waRmZip.wsf BASE [/ca:value] [/cp:value] [/cpp:value] [/ce:value] [/da:value] [/dc] [/df] [/dr] [/ma:value] [/md:value] [/mb] [/ra:value] [/rn:value] [/rp:value] [/fo:value] [/fn:value] [/gt:value] [/lt:value] [/r] [/nh] [/t] [/v] [/q] [/log:value]Options:
BASE : base folder where cleanup starts
ca : compress files after X days (default: no compress)
cp : compress program - command line (default: wzzip.exe)
cpp : compress program - command parameters (default: folder\$out $folder\$in)
ce : compressed file extension (default: .zip)
da : delete files after X days (default: no delete)
dc : delete compressed files too after X days (default: don’t delete archives)
df : delete empty folders - only when /r is used (default: don’t delete folders)
dr : delete read-only files/folders (default: don’t delete read-only)
ma : move files after X days (default: no backup)
md : move files to this folder (can be local or UNC) (default: /ma does not work without this parameter)
the following keywords are substituted:
$YEAR: YYYY, $MONTH: YYYYMM, $DAY: YYYYMMDD, $HOUR: HH, $COMP: COMPUTERNAME, $WEEKDAY: 1-7
e.g: /md:F:\backup\$COMP\logfiles\$DAY
mb : backup mode - do not delete file after moving (default: delete)
ra : rotate files after X days (creation date!) (default: no rotate)
rn : rotate & create new empty file after rotation (default: do not create)
rp : rotation prefix - D:YYYYMMDD (default: D)
fo : filter only - only process files with extension (default: process all files)
fn : filter not - don’t process files with extension(default: process all files)
gt : greater than- only process when larger than (default: 0 KB)
lt : lesser than - only process when smaller than (default: 1 GB)
r : recursive - also process subfolders (default: don’t process subfolders)
nh : no hidden - do not process hidden files/folders(default: just process them)
t : test mode - don’t actually process files - just show what would be done
v : verbose - show debug output during execution
q : quiet - no output during execution
log : logfile - write output to file
if filename=’D’ use [script name].YYYYMMDD.log as log file
if filename=’M’ use [script name].YYYYMM.log as log file
if no filename given use [script name].log as log file
Examples:
waRmZip.wsf /r “C:\Inetpub\ftproot” /da:7 /df /dr /log:c:\Inetpub\ftp_cleanup.log
:: clean up FTP folders - delete all files older than 7 days and empty folders, even if read-only
waRmZip.wsf /r /f:.log “C:\WINNT\system32\Logfiles” /da:30 /dc /ca:14 /log:d
:: compress all log files older than 14 days, delete all files older than 30 days
waRmZip.wsf /r “C:\Temp” /da:1 /df /q
:: delete all files older than 1 day, don’t show output
waRmZip.wsf “d:\server\log” /ra:7 /fo:.txt /gt:1MB /log:d
:: rotate all .txt files greater than 1MB created more than 7 days ago
waRmZip.wsf /r /f:.log “C:\WINNT\system32\Logfiles” /ma:7 /md:f:\backup\$YEAR\$COMP\$DAY\IIS
:: move all log files older than 7 days to folder F:\backup\2004\server1\20040101\IIS
waRmZip.wsf /r /f:.log “C:\WINNT\system32\Logfiles” /ca:14 /cp:”c:\Program Files\7-Zip\7za.exe” /cpp:”a -tzip $out $in”
:: compress all log files older than 14 days with 7-Zip
===== HISTORY =====
:: v1.7 - 2005-11-21 - fix paths with spaces, add $WEEKDAY
:: v1.6 - 2004-07-12 - fix move/copy bug for folder trees
:: v1.5 - 2004-06-15 - fixed filter bug, better rotate feedback
:: v1.4 - 2004-03-10 - adapted for waCron.cmd, added /nh, max age in h/d/w/m
:: v1.3 - 2004-02-24 - worked on the /log functionality
:: v1.2 - 2004-01-15 - added ‘move’ functionality
:: v1.1b- 2003-11-18 - fixed /log:d bug - .zip.zip bug
:: v1.1 - 2003-10-31 - added rotation/stats - fixed some bugs (e.g. /df)
:: v1.0 - 2003-09-01 - First public release
Enjoy this great utility!
Download the .zip archive: