Sign in to follow this  
Followers 0
caocao81

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

7 posts in this topic

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?

Share this post


Link to post
Share on other sites

2. DirRemove()

Share this post


Link to post
Share on other sites

2. DirRemove()

for example: I want to del all the file and subdirctoy in dirctory E:\temp, but if use DirRemove("E:\temp\",1) , it will del the E:\temp also, but this dirctory not need to del.

Thank U for your reply!

Share this post


Link to post
Share on other sites

DirRemove(), DirCreate()...

Share this post


Link to post
Share on other sites

DirRemove(), DirCreate()...

any other method?

Share this post


Link to post
Share on other sites

$folder = "c:\test"

FileOpen($folder, 0)
DirRemove($folder, 1)
FileClose($folder)

Share this post


Link to post
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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0