caocao81 Posted October 11, 2007 Share 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? Link to comment Share on other sites More sharing options...
Shevilie Posted October 11, 2007 Share 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 Link to comment Share on other sites More sharing options...
caocao81 Posted October 11, 2007 Author Share Posted October 11, 2007 a guess $Path1 = "E:\Temp\*"I try, not this reason , also thank you! Link to comment Share on other sites More sharing options...
dabus Posted October 11, 2007 Share 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. Link to comment Share on other sites More sharing options...
caocao81 Posted October 12, 2007 Author Share 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! Link to comment Share on other sites More sharing options...
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