Kaseya Community

Delete Files older than 21 Days

  • Hi All.

    I have a client using external USB Drives x 3, and Norton Save and Restore. The problem is S&R will sometimes not remove the older backup sets.

    I am looking at creating a script to 1. get #currentdate#, 2. get file attributes (name, size and date created) of all files on the backup drive (YSmile 3. compare the file dates to the current date - 4. remove files older than say 21 days.

    Have had a look through the forum and nothing jumps out at me - has anyone tried to automate this - or would anyone have any suggestions on steps 3 and 4? (Or even a totally different way of achieving this?)

    Thanks in advance

    Carey

    Legacy Forum Name: Delete Files older than 21 Days,
    Legacy Posted By Username: carey-pccare
  • If they're in the same directory every time, you could use DelOld, which is what I'm using to keep a particular webserver's ginormous logfiles under control...

    Script Name: Clear Old IIS Logs on HDI-PORTAL - kk
    Script Description:

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\DelOld.exe
    Parameter 2 : kkerezman\DelOld.exe
    OS Type : 13
    Execute Shell Command
    Parameter 1 : #vAgentConfiguration.agentTempDir#\DelOld.exe C:\WINDOWS\system32\LogFiles\W3SVC1474758353\*.* 21
    Parameter 2 : 1
    OS Type : 13
    ELSE


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • GreyDuck
    If they're in the same directory every time, you could use DelOld, which is what I'm using to keep a particular webserver's ginormous logfiles under control...

    Script Name: Clear Old IIS Logs on HDI-PORTAL - kk
    Script Description:

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\DelOld.exe
    Parameter 2 : kkerezman\DelOld.exe
    OS Type : 13
    Execute Shell Command
    Parameter 1 : #vAgentConfiguration.agentTempDir#\DelOld.exe C:\WINDOWS\system32\LogFiles\W3SVC1474758353\*.* 21
    Parameter 2 : 1
    OS Type : 13
    ELSE


    Hi GreyDuck, thanks for that. I didn't even know that executable existed. I've had a look and that will do exactly what I need.

    Cheers, Carey

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: carey-pccare