By Pinkel (Submitted By  superurbi)Created 04 Nov 2011, Modified 09 Nov 2011
My Rating:
Vote
Rating:
Not Rated
Views:6484
Downloads:61
Source:

Cleanup old files depending on the age of x days, folder and file extension

Language:  VBScript

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Yes Windows 2008 Yes
Description

Cleanup old files depending on the age of x days, folder and file extension

Code

Line Numbers: On  Off      Plain Text
'********************************************************************************
' name:     Cleanup.vbs
' function: Cleanup old files depending on the age of X days, folder and file ext
' options:  /dir:*  /days:* /? (*=requiered)
' author:   Pinkel
' version:  1.1
' date:     01-04-2011
' correction date: 03-11-2011
' correction author: superurbi
'********************************************************************************
Option Explicit
Dim wshArgs, wshShell
Dim FilePath, Retention, FileFilter, FilterExt
Dim fso, writelog, Folder, xFileDelete, xErrorDelete
Set wshArgs = wscript.arguments
Set wshShell = wscript.createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If ChkArgs = True then
	FilePath = wshArgs.named.item("dir")
	Retention = wshArgs.named.item("days")
	FilterExt = wshArgs.named.item("ext")
	Set writelog = fso.OpenTextFile( FilePath & "\" & GetLogName(), 8, True)
	writelog.writeline "Operation cleanup started in " & FilePath & " on " & Date & ", at " & Time & "."
	writelog.writeline "Cleaning files from " & FilePath & " older then " & Retention & " days."
	DelFiles FilePath, Retention, FileFilter
	writelog.writeline "Operation cleunup finished in " & FilePath & " on " & Date & ", at " & Time & "."
Else
	ShowUsage 1
	wshShell.LogEvent 2, "Operation cleanup failed (Cleanup.VBS). Requiered options are missing."
	wscript.echo "Operation cleanup FAILED!"
	wscript.echo "Requiered options are missing."
End If
Set wshArgs = Nothing
Set wshShell = Nothing
Set fso = Nothing
FilePath = ""
Retention = ""
Function ChkArgs
	Dim PathArg, DaysArg, ExtArg, HelpArg
	PathArg = wshArgs.Named.exists("dir")
	DaysArg = wshArgs.named.exists("days")
	ExtArg = wshArgs.named.exists("ext")
	HelpArg = wshArgs.named.exists("?")
	If HelpArg = True then
		ShowUsage 0
		wscript.quit
	End If
	If PathArg = True and DaysArg = True then 
		ChkArgs = True
	Else
		ChkArgs = False
	End If
	If ExtArg = True then
		FileFilter = True
	Else
		FileFilter = False
	End If
End Function
Function GetLogName
	GetLogName = Year(Now()) & Month(Now()) & Day(Now()) & "-optuim.log"
End Function
Sub ShowUsage(Mode)
	wscript.echo "CLEANUP.VBS ussage:" & _
	vbcrlf & _
	vbcrlf & _
	" Cleanup.vbs /dir:[path] /days:[older than x days] /ext:[file extension]" & _
	vbcrlf & _
	"path = Folder location of the files." & _
	vbcrlf & _
	"older then x days = Required life time of files, older files will be deleted." & _
	vbcrlf & _
	"file extension = option: Cleaning files with an exention (only the extension, no dot)" & _
	vbcrlf & _
	"All files older than x days, will be deleted." 
	If Mode = 0 then
		wscript.quit
	Else
	End If
End Sub
Sub DelFiles(Dir, days, DelFilter)
	Dim DelDate, FSO, Folder, SubFolder, SubDir, Files, File, FileDate, Ext, FileDelete, ErrorDelete
	Set FSO = createobject("scripting.filesystemobject")
	On Error Resume Next
	Set Folder = FSO.GetFolder(Dir)
	If Err.Number = 76 then
		wscript.echo "Operation cleanup FAILED! - Folder not found."
		wshShell.LogEvent 2, "Operation cleanup FAILED! (Cleanup.VBS) - Folder not found."
		wscript.quit
	End If
	ErrorDelete = 0
	FileDelete = 0
	DelDate = Now - days
	On Error Goto 0
	Set Files = Folder.Files
	Set SubFolder = Folder.SubFolders
	For each File in Files
		FileDate = File.DateLastModified
		Ext = FSO.GetExtensionName(File)
		On Error Resume Next
		If DelFilter = True then
			If FileDate <= DelDate and Ext = FilterExt then
				File.Delete
				FileDelete = FileDelete + 1
			End If
			Else
			If FileDate <= DelDate then
				File.Delete
				FileDelete = FileDelete + 1
			End If
		End If
		If Err.Number = 70 Then
			wscript.echo "File " & Dir & "\" & File.Name & _
			" not deleted: Failed - ACCESS DENIED!"
			wshShell.LogEvent 2, "File " & Dir & "\" & _
			File.Name & " not deleted: Failed - ACCESS DENIED! (Cleanup.VBS)"
			writelog.writeline "File " & Dir & "\" & File.Name
			writelog.writeline " not deleted: Failed - ACCESS DENIED!" & Time
			ErrorDelete = ErrorDelete + 1
		End If
		On Error Goto 0
	Next
	
	For each SubDir in SubFolder
		DelFiles SubDir.Path, days, DelFilter
	Next
	
	writelog.writeline FileDelete & " files deleted from folder " & Dir & "."
	writelog.writeline ErrorDelete & " errors found."
	
	Set Files = Nothing
	Set Folder = Nothing
	Set FSO = Nothing
	FileDelete = ""
	ErrorDelete = ""
End Sub 

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      

Posted On: 9/28/2018 1:26:14 AM

ugg outlet canada goose outlet cheap jerseys air jordan 4 polo ralph lauren ugg outlet christian louboutin outlet coach outlet online polo ralph lauren michael kors outlet pandora outlet ugg outlet canada goose outlet canada goose outlet true religion jeans vibram fivefingers adidas nmd shoes moncler jackets true religion outlet yeezy boost ugg outlet air max 90 uggs outlet nike huarache pandora jewelry ugg boots clearance michael kors outlet michael kors handbags canada goose outlet canada goose outlet pandora charms true religion jeans nfl jerseys wholesale canada goose jackets coach outlet christian louboutin outlet coach outlet christian louboutin outlet longchamp handbags michael kors outlet michael kors outlet pandora charms christian louboutin outlet christian louboutin outlet canada goose jackets adidas yeezy michael kors outlet polo ralph lauren valentino outlet coach outlet pandora jewelry pandora outlet mont blanc pens air max 90 birkenstock outlet nike trainers nike outlet lebron james shoes coach outlet adidas outlet kate spade outlet polo outlet hermes birkin kate spade outlet moncler outlet uggs outlet ray ban sunglasse mont blanc pens michael kors handbags polo ralph lauren coach outlet coach outlet coach outlet online canada goose jackets coach outlet store online coach outlet online mbt shoes polo ralph lauren coach outlet pandora jewelry moncler outlet canada goose outlet pandora jewelry michael kors outlet michael kors outlet pandora outlet coach factory outlet ray ban sunglasses canada goose outlet michael kors outlet ugg outlet canada goose jackets michael kors outlet coach outlet ralph lauren uk christian louboutin outlet michael kors outlet oakley sunglasses wholesale polo outlet coach outlet adidas outlet nfl jerseys wholesale christian louboutin outlet nike shoes canada goose jackets cheap nfl jerseys lebron james shoes coach outlet kate spade outlet polo shirts christian louboutin outlet ferragamo outlet cheap ugg boots michael kors outlet clearance superdry clothing michael kors handbags oakley sunglasses wholesale coach outlet coach outlet canada canada goose outlet michael kors outlet north face jackets kate spade outlet cheap ugg boots polo ralph lauren canada goose outlet true religion outlet store kate spade outlet michael kors outlet coach outlet online fred perry polo shirts ultra boost christian louboutin outlet prada outlet christian louboutin outlet kate spade outlet off white clothing kate spade outlet moncler jackets kate spade outlet christian louboutin outlet air jordan shoes coach outlet online kate spade outlet pandora outlet christian louboutin outlet moncler jackets polo ralph lauren mbt shoes ugg outlet coach outlet ugg outlet ralph lauren polo michael kors handbags ralph lauren outlet coach factory outlet cheap jordans chaussures christian louboutin michael kors outlet ugg outlet kate spade outlet canada goose jackets polo outlet michael kors outlet nfl jerseys pandora outlet coach outlet coach factory outlet ray ban sunglasse supreme uk michael kors outlet nfl jerseys canada goose jackets coach outlet true religion outlet scarpe mbt michael kors outlet air max 2017 nfl jerseys wholesale pandora jewelry outlet cheap jordans coach outlet online ray ban outlet nfl jerseys wholesale michael kors outlet coach factory outlet michael kors outlet christian louboutin outlet canada goose outlet coach outlet oakley sunglasses wholesale michael kors outlet clearance supreme outlet mont blanc pens coach factory outlet cheap mlb jerseys true religion jeans nba jersey mlb jerseys wholesale ray ban sunglasses canada goose outlet christian louboutin outlet oakley sunglasses nike shoes cheap nfl jerseys birkenstock shoes ed hardy clothing oakley sunglasses mulberry handbags ralph lauren shirts michael kors outlet nike outlet coach outlet michael kors outlet polo ralph lauren cheap nfl jerseys ugg boots michael kors outlet coach outlet asics running shoes pandora charms michael kors outlet nfl jerseys wholesale pandora charms pandora charms uggs outlet uggs outlet christian louboutin mbt shoes canada goose outlet tory burch outlet coach factory outlet pandora charms michael kors outlet coach outlet yeezy boost ralph lauren sale clearance mulberry handbags adidas nmd mlb jerseys canada goose outlet coach outlet michael kors outlet ugg outlet kate spade outlet ugg outlet ray ban sunglasse adidas yeezy mulberry handbags coach outlet mbt shoes nike outlet michael kors outlet pandora outlet mbt shoes ugg boots nike shoes outlet coach factory outlet michael kors outlet clearance coach outlet online coach outlet north face jackets ugg outlet polo outlet yeezy boost polo ralph lauren christian louboutin outlet polo ralph lauren ralph lauren polo shirts coach outlet online adidas nmd ugg outlet coach outlet coach outlet fitflops sale clearance pandora outlet valentino outlet nike shoes coach outlet michael kors handbags canada goose jackets michael kors handbags canada goose outlet fitflops sale clearance ray ban sunglasses cheap oakley sunglasses polo outlet moncler outlet canada goose outlet adidas yeezy shoes coach outlet nfl jerseys oakley sunglasses wholesale polo ralph lauren kate spade outlet ray ban sunglasses canada goose jackets adidas outlet coach outlet pandora outlet michael kors outlet coach outlet coach outlet online cheap ray bans sunglasses coach outlet michael kors outlet lunette ray ban michael kors taschen michael kors outlet true religion outlet nike outlet christian louboutin outlet ugg boots pandora charms air jordan retro coach outlet mont blanc pens nhl jerseys red bottom shoes true religion outlet mbt shoes louboutin shoes michael kors outlet asics shoes canada goose jackets polo ralph lauren gucci outlet christian louboutin outlet coach outlet coach outlet canada goose rolex watches michael kors handbags coach factory outlet michael kors outlet pandora charms sale clearance canada goose outlet polo ralph lauren pas cher oakley sunglasses michael kors outlet giuseppe zanotti outlet canada goose outlet polo outlet canada goose outlet moncler jackets christian louboutin outlet coach factory outlet nike outlet coach outlet online nike outlet tory burch outlet kate spade handbags fred perry polo fred perry polo shirts red bottom shoes cheap ugg boots coach outlet cheap nfl jerseys coach outlet ralph lauren shirts true religion jeans christian louboutin boutique north face jackets prada handbags christian louboutin outlet nfl jerseys christian louboutin outlet pandora jewelry polo ralph lauren mcm handbags moncler outlet true religion outlet polo ralph lauren polo outlet cheap nfl jerseys coach outlet cheap ugg boots coach outlet online pandora jewelry pandora jewelry mbt shoes pandora outlet nfl jerseys pandora charms coach outlet uggs outlet coach outlet online longchamp outlet coach outlet nike air max ugg boots ugg boots michael kors handbags canada goose jackets adidas superstar shoes cheap snapbacks giuseppe zanotti outlet adidas shoes michael kors outlet red bottom shoes fitflops sale clearance pandora charms christian louboutin outlet canada goose outlet coach outlet polo ralph lauren fitflops sale clearance christian louboutin outlet coach outlet mulberry handbags oakley sunglasses michael kors outlet michael kors handbags gucci outlet michael kors outlet moncler outlet north face jackets mcm outlet puma outlet coach outlet nhl jerseys cheap jordans uggs outlet hermes belts manolo blahnik outlet cheap ugg boots michael kors outlet ralph lauren outlet ugg outlet north face jackets adidas outlet ralph lauren outlet polo ralph lauren ed hardy kate spade outlet ugg outlet canada goose jackets ralph lauren polo christian louboutin shoes uggs outlet canada goose jackets pandora charm ugg boots clearance cheap nfl jerseys canada goose jackets pandora jewelry cheap jerseys kate spade outlet yeezy boost ugg outlet michael kors outlet uggs outlet nike kyrie 3 off-white canada goose outlet pandora outlet lacoste outlet nike shoes michael kors outlet michael kors outlet oakley sunglasses tory burch outlet coach outlet ralph lauren outlet ugg boots ralph lauren outlet kate spade outlet polo ralph lauren christian louboutin outlet pandora outlet michael kors outlet ugg outlet coach outlet red bottoms michael kors outlet uggs canada ugg boots nike outlet polo ralph lauren uggs outlet coach outlet christian louboutin outlet converse adidas nmd pandora jewelry coach outlet true religion jeans yeezy boost 350 coach outlet polo outlet christian louboutin outlet fred perry outlet michael kors handbags oakley sunglasses ray ban sunglasses polo ralph lauren uggs outlet canada goose outlet canada goose outlet canada goose jackets michael kors handbags clarks shoes adidas yeezy pandora charms oakley sunglasses kate spade outlet prada outlet ferragamo shoes tory burch outlet valentino outlet polo outlet coach outlet online uggs canada true religion jeans canada goose outlet coach outlet online christian louboutin shoes pandora outlet pandora outlet michael kors outlet kate spade outlet michael kors uk michael kors outlet michael kors outlet canada goose jackets cheap jordans polo outlet ugg boots longchamp outlet michael kors outlet christian louboutin outlet michael kors outlet pandora outlet ray ban sunglasse supreme ugg boots michael kors outlet rolex watches kobe bryant shoes moncler outlet canada goose vans shoes michael kors outlet michael kors outlet kebirong20180928

daisyjane2018
Posted On: 11/9/2018 1:27:52 AM

The league announced the news this morning, writing in a press release that,cheap authentic jerseys "Beginning Friday, November 9, NFL team 'outfits' will be available in the cheap nfl jerseys Shop. This unique opportunity will give Fortnite players the ability to purchase and customize up to eight outfits representing their favorite NFL teams."cheap jerseysWe're just getting started, though! There will also be "football-themed emotes, harvesting tools, gliders, and even a referee outfit." cheap sports jerseys Even a referee outfit! cheap jerseys from chinaSo there you have it, Fortniters (Fortnitees?). Your prayers have been answered. Everyone gets their favorite team's football jersey,wholesale jerseys and themed emotes, and harvesting tools, and gliders. Click here to choose the new cheap authentic jerseys from china and wholesale nfl jerseys! Receive comprehensive coverage of the Bears and stream the ‘Football Aftershow’ easily on your device.click here cheap authentic nfl jerseys.It's not a giant surprise,custom cowboys jersey but it's still impressive to see. Fortnite is hugely popular among professional athletes, and it's football season,discount jerseys after all. Epic Games just announced an official partnership with the NFL to bring licensed jerseys to the popular battle royale game, letting players don the jerseys of their favorite teams as they blast each other into oblivion.discount nfl jerseys cheap nfl jerseys cheap jerseys cheap jerseys from china wholesale jerseys cheap nfl jerseys from china china jerseys nfl jerseys china wholesale nfl jerseys cheap authentic nfl jerseys cheap jerseys online cheap authentic jerseys cheap sports jerseys cheap wholesale jerseys china wholesale jerseys discount nfl jerseys cheap authentic jerseys from china discount jerseys custom cowboys jersey Click here GOOGLE FACKBOOK Amazon nfl jerseys cheap cheap college football jerseys cheap nfl jerseys china cheap football jerseys custom jerseys cheap cheap nfl gear cheap nfl authentic jerseys cheap jerseys nfl nfl football jerseys cheap cheap nfl football jerseys cheap nfl jerseys free shipping cheap nfl nike jerseys custom nfl jerseys cheap nfl cheap jerseys

daisyjane2018
Posted On: 1/17/2019 2:29:17 AM

sac a main michael kors pas cher basket femme pas cher maillot foot pas cher maglie nba a poco prezzo michael kors borse prezzi borse michael kors prezzi maglie calcio a poco prezzo maglie calcio poco prezzo maglie calcio 2019 comprar camisetas de futbol camisetas nba baratas comprar camisetas nba camisetas de nba baratas camisetas de futbol baratas camisetas futbol baratas coach outlet online coach outlet store online coach factory outlet online store coach factory outlet online coach factory outlet online login cheap coach handbags coach factory outlet store coach factory store online cheap nfl jerseys cheap nfl jerseys from china wholesale nfl jerseys cheap polo ralph lauren online kate spade outlet real madrid trikot nba trikots fussball trikots fußball trikot bayern münchen trikot nike trikot schalke trikot 18 19 bayern trikot 2019 fc barcelona trikot neymar trikot atletico madrid trikot football trikot deutschland trikot kinder michael kors outlet michael kors outlet online michael kors factory outlet cheap michael kors bags cheap michael kors purses cheap michael kors chaussures louboutin pas cher christian louboutin louis benech coach outlet store online coach factory outlet online cheap coach purses official coach factory outlet online coach factory outlet online login official coach outlet online cheap coach handbags coach factory store online coach outlet online coach factory outlet coach purses cheap cheap coach handbags coach factory outlet store coach factory store online michael kors outlet online cheap michael kors bags nba sportando nba store eu canotte nba cinema moderno maglie canotte nba a poco prezzo cheap nfl jerseys cheap jerseys from china cheap authentic jerseys cheap nfl authentic jerseys cheap jerseys online cheap polo ralph lauren outlet cheap polo ralph lauren online dortmund trikot manchester united trikot bayern münchen trikot bvb trikot 18 19 maillot de foot pas cher maillot foot pas cher maillot de foot pas cher net cheap football shirts

daisyjane2018
Posted On: 2/21/2019 9:20:25 AM

cheap coach handbags maglie calcio 2019 cheap authentic jerseys coach outlet clearance coach outlet online cheap jerseys online cheap polo ralph lauren online official coach outlet online atletico madrid trikot borse michael kors prezzi camisetas futbol baratas cinema moderno maglie cheap nfl jerseys from china comprar camisetas nba comprar camisetas de futbol tu dortmund unimail sportando nba cheap nfl jerseys maglie calcio poco prezzo cheap nfl authentic jerseys coach factory outlet online login dortmund trikot coach factory outlet online login michael kors borse prezzi coach factory outlet camisetas de nba baratas coach outlet online michael kors borse prezzi coach factory store online neymar trikot coach factory outlet store michael kors outlet online schalke trikot 18 19 deutschland trikot kinder coach factory store online official coach factory outlet online maillot de foot pas cher camisetas de futbol baratas cheap jerseys from china cheap jerseys from china wholesale nfl jerseys maillot de foot pas cher net kate spade outlet cheap coach purses fussball trikots maglie calcio a poco prezzo michael kors outlet coach factory outlet online store nike trikot canotte nba a poco prezzo nba tabellenstand cheap michael kors bags maglie nba a poco prezzo basket femme pas cher real madrid trikot christian louboutin louis benech coach factory outlet store michael kors borse prezzi cheap nfl jerseys chaussures louboutin pas cher maillot foot pas cher cheap nfl jerseys cheap football shirts cheap coach handbags coach outlet store online camisetas nba baratas

daisyjane2018
Posted On: 6/19/2019 8:51:45 AM

??? ?????? ????? ??? ??? ?????? ????? ??? ??? ?????? ?? ??? ??? ?????? ??? ?????? ????? ??? ??? ?? ?????? ??? ?????? ?? ??? ?????? ?????? ??? ??? coach outlet coach outlet clearance coach outlet clearance sale real psg streaming mel ouvert caen borse michael kors michael kors borse outlet sfondi juventus calciomercatonapoli24 pecnapoli mosca rossa torino coach outlet clearance coach purses on clearance stan stephens coupon code cheap nfl jerseys cheap jerseys from china wholesale nfl jerseys prefisso 045 itmagliecalcio shop dobre com cheap phone cases rosewholesale wigs afiba wigs bounty camisetas bounty camisetas vipleague nbaplus horarios nba eu nba sportando michael kors rea michael kors plånbok coach crossbody coach factory outlet online michael kors borse prezzi pochette michael kors borse michael kors outlet cheap authentic jerseys cfb3 camisetas bounty camisetas michael kors plånbok cheap custom phone cases michael kors plånbok official coach outlet online cheap wigs borse michael kors camisetas de futbol baratas camisetas futbol baratas cheap nfl jerseys cheap t shirts cheap t shirt design cheap custom shirts wholesale phone cases cheap jerseys from china cheap lace front wigs cheap nhl jerseys custom t shirts cheap coach factory outlet online cheap phone cases cheap dress shirts cheap lace front wigs cheap authentic jerseys cheap custom shirts www coachoutlet com official coach outlet online mascamisetasnba coach factory outlet online maillot om pas cher survetement foot pas cher maillot equipe de france pas cher coach outlet online coach factory outlet online michael kors väska michael kors plånbok michael kors väska rea michael kors plånbok michael kors väska rea michael kors outlet bolsos michael kors outlet michael kors españa michael kors el corte ingles bolsos michael kors el corte ingles nba sportando nba store eu canotte nba sportando nba maglie nba cheap nfl jerseys cheap jerseys online backpage north jersey backpage jersey shore discount nfl jerseys cheap nhl jerseys cheap nba jerseys cheap ralph lauren polo shirts polo ralph lauren outlet online ralph lauren outlet online rosewholesale wigs afiba wigs rosewholesale wig reviews khabib wig cheap wigs maillotfoot co max maillot maillot thailande maillot equipe de france pas cher maillot psg pas cher cfb3 camisetas camisetas de futbol replicas camisetas de futbol replicas camisetas de futbol baratas notiziario del calcio foggia calcio mania risultati calcio ieri notiziario del calcio serie d foggiacalciomania cfb3