Jump to content

Using a batch file to delete .log older than 2 weeks


Recommended Posts

With AutoIt you can see for FileGetTime function ! Posted Image

Example :

#include <Date.au3>

$_FileTime = FileGetTime ( @WindowsDir & "\explorer.exe", 1, 1 ) 
$_DayDiff = _DateDiff ( 'd', _ConvertTimeFormat ( $_FileTime ), _NowCalc ( ) )
MsgBox ( 4096, "", "Number of days since : " & $_DayDiff )

Func _ConvertTimeFormat ( $_FileTime ) 
    Return StringMid ( $_FileTime, 1 , 4 ) & '/' & StringMid ( $_FileTime, 5 , 2 ) & '/' & StringMid ( $_FileTime, 7 , 2 ) & _
    ' ' & StringMid ( $_FileTime, 9 , 2 ) & ':' & StringMid ( $_FileTime, 11 , 2 ) & ':' & StringMid ( $_FileTime, 13 , 2 )
EndFunc ;==> _ConvertTimeFormat ( )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Luuk mow bettuh

forfiles.exe /P "PathToDirectory" /M *.log /D -15 /C "cmd /c del /q @PATH"

forgot: For recursive directory search

forfiles.exe /P "PathToDirectory" /S /M *.log /D -15 /C "cmd /c del /q @PATH"

CAPITALS for switches are MANDATORY!!!

Edited by Varian
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...