Sign in to follow this  
Followers 0
caocao81

How to del all files?

5 posts in this topic

How to del all files? This is my script:

$Path1 = "E:\Temp\*.*"

$t = FileGetTime( $Path1 )

Select

Case @YEAR > $t[0]

$Return = FileDelete( $Path1 )

If $Return =1 Then

MsgBox(64, "Result", "Del Success")

Else

MsgBox(16, "Result", "Del Faile")

EndIf

Case @YEAR <= $t[0] and @MON > $t[1]

$Return = FileDelete( $Path1 )

If $Return =1 Then

MsgBox(64, "Result", "Del Success")

Else

MsgBox(16, "Result", "Del Faile")

EndIf

Case @YEAR <= $t[0] and @MON <= $t[1] and @MDAY - $t[2] >=7

$Return = FileDelete( $Path1 )

If $Return =1 Then

MsgBox(64, "Result", "Del Success")

Else

MsgBox(16, "Result", "Del Faile")

EndIf

EndSelect

when run script, have no error info, but all the files in "E:\Temp\", no one have del, when I change the $Path1 = "E:\Temp\*.*" to $Path1 = "E:\Temp\*.txt", script can del all the file *.txt, why can't del all the file?

Share this post


Link to post
Share on other sites

a guess $Path1 = "E:\Temp\*"


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

a guess $Path1 = "E:\Temp\*"

I try, not this reason , also thank you!

Share this post


Link to post
Share on other sites

You do no search. :)

Try to melt your sript with this (not checked):

$Path1 = "E:\Temp"
; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile($Path1&"\*.*")  
; Check if the search was successful
If $search <> -1 Then
While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
; Put your stuff here
$t = FileGetTime( $Path1&"\"&$file )
; and so on
WEnd
; Close the search handle
FileClose($search)
EndIf

And please have a look at the helpfile.

Share this post


Link to post
Share on other sites

You do no search. :)

Try to melt your sript with this (not checked):

$Path1 = "E:\Temp"
; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile($Path1&"\*.*")  
; Check if the search was successful
If $search <> -1 Then
While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
; Put your stuff here
$t = FileGetTime( $Path1&"\"&$file )
; and so on
WEnd
; Close the search handle
FileClose($search)
EndIf

And please have a look at the helpfile.

Thank you very much! It can work!

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