Jump to content

How to get the edit time of dirctory and how to del all the file in a dirctory include subdirctory ?


 Share

Recommended Posts

1. I want to get the edit time of the dirctory, if the time is 7 days ago, I need to del it, so I need to get the time, but in autoit help files, I found only a function for file "FileGetTime", how to get the edit time of the dirctory?

2. I need to del all the file in a dirctory, the dirctory have a lot of subdirctory, subdrictory also have a lot of file in it. how to del all?

Link to comment
Share on other sites

Would something like suffice?

#include <Array.au3>
#Include <Date.au3>
$dir = FileSelectFolder ("Select Folder", "")
$data = ""
$time = FileGetTime ($dir)
$time = $time[0] & "/" & $time[1]  & "/" & $time[2]
$current = _NowCalcDate ( ); YYYY/MM/DD

If _DateDiff ("D", $time, $current) >= 7 Then
    DirRemove ($dir, 1)
    DirCreate ($dir)
    $data = "DIRECTORY ("&$DIR&") REMOVED.  DIRECTORY RE-CREATED" & @CRLF
Else
    $data = "DIRECTORY ("&$DIR&") NOT OLD ENOUGH TO BE REMOVED" & @CRLF &
EndIf

ConsoleWrite ($data)
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...