VBS Script to clean up old files when folder is x Mb

Security kit creates logs, aparently some people use something called windows server instead of linux as their file & log servers :)

Recently I had a requirement whereby if a folder was larger than 30Gb (approx 95% of a partition) then the oldest files should be deleted, usually bash would be the answer but in this instance I needed to use a visual basic script.

This is what I came up with, it’s not neat (cause I don’t know vbs) but it works, if you want to use it find and replace “D:\Files” with your directory then find & replace “35000” with your required size in Mb (35000Mb is approx 35Gb) , save the attached script .txt file (vbs_script_disk_clean_up.txt) as script.vbs, then use task scheduler to run everyday, job done!

rgds,

Nick

VBS Script to Clean Up Old files

VBS Script to Clean Up Old files

This visual basic script will delete old files from a folder if that folder is greater than a given size!


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>