Jump to content

How to del all files?


 Share

Recommended Posts

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?

Link to comment
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.

Link to comment
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!

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...