Jump to content
Sign in to follow this  
caocao81

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

Recommended Posts

caocao81

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
caocao81

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
rasim

$folder = "c:\test"

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

Share this post


Link to post
Share on other sites
BrettF

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.