caocao81 Posted October 11, 2007 Posted October 11, 2007 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?
Shevilie Posted October 11, 2007 Posted October 11, 2007 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
caocao81 Posted October 11, 2007 Author Posted October 11, 2007 a guess $Path1 = "E:\Temp\*"I try, not this reason , also thank you!
dabus Posted October 11, 2007 Posted October 11, 2007 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.
caocao81 Posted October 12, 2007 Author Posted October 12, 2007 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now