Muzzikap 0 Posted January 17, 2005 (edited) What is the reason that when i try to delete a directory the directory won't be deleted? What am I doing wrong? I have tried FileRecycle , DirRemove but these two commands just simply don't seen to work I keep getting the messagebox: MsgBox(0, "Failed removing dir", "Failed removing dir");Please go easy on my way of scripting. It's my first Autoit script.expandcollapse popup$StartDir= "F:\automatiseren op pc\oefenen\Download\" $Submaps= "" Global $dir_list[50]; Main(); Func Main() $i = 0; while 1 $dir = $StartDir & $Submaps $Zoek = FileFindFirstFile( $dir & "*.*") If $Zoek = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($Zoek) If @error Then if NietinArray($file) then MsgBox(0, "Remove dir and restart search", $dir); if DirRemove ( $dir) = 0 then MsgBox(0, "Failed removing dir", "Failed removing dir"); $Submaps= "" ExitLoop EndIf EndIf if $file = "." OR $file = ".." then ContinueLoop if (StringInStr($dir & "*",FileGetAttrib ($file), "D") AND NietinArray($file)) then $t = FileGetTime($dir & $file, 1); If @error Then $Submaps=$Submaps& $file & "\" MsgBox(0, "Directory found", $file); ExitLoop EndIf endif if (StringInStr($dir & "*",FileGetAttrib ($file), "N"))then MsgBox(0, "Found file in dir", $file); if StringInStr($file, "par2") then CheckRar($dir) Reset(); ExitLoop Else $dir_list[$i] = $file; MsgBox(0, "Dir to array", $file); $i = $i + 1; Endif EndIf WEnd FileClose($Zoek) WEND EndFunc Edited January 17, 2005 by Muzzikap Share this post Link to post Share on other sites
Josbe 1 Posted January 17, 2005 Sry, but are you sure if this file/dir can be deleted manually? Returns 0 if there is an error removing the directory (or if directory does not exist). AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Share this post Link to post Share on other sites
Muzzikap 0 Posted January 17, 2005 Sry, but are you sure if this file/dir can be deleted manually? <{POST_SNAPBACK}> I can delete/move the directory using windows explorer. I guess that is enough to see that i can remove the dir manually?if it doesn't work this way please explain to me how i can see if i can delete this folder manually Share this post Link to post Share on other sites
Josbe 1 Posted January 17, 2005 hmm... change this line: if DirRemove ( "$dir") to if DirRemove ( $dir) AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Share this post Link to post Share on other sites
Muzzikap 0 Posted January 17, 2005 hmm...change this line:if DirRemove ( "$dir")toif DirRemove ( $dir)<{POST_SNAPBACK}>Thanks I changed it. but that wasn't the solution. I still got the same problem Share this post Link to post Share on other sites
SlimShady 1 Posted January 17, 2005 (edited) Quote from the help file/online docs:recurse [optional]Use this flag to specify if you want to delete sub-directories too. 0 = (default) do not remove files and sub-directories 1 = remove files and subdirectories (like the DOS DelTree command)So change:if DirRemove ( $dir)to:if DirRemove ($dir, 1) Edited January 17, 2005 by SlimShady Share this post Link to post Share on other sites
Muzzikap 0 Posted January 17, 2005 Quote from the help file/online docs:So change:if DirRemove ( $dir)to:if DirRemove ($dir, 1)<{POST_SNAPBACK}>already tried that one aswell. tomorrow i will add some commentary to my script and then post it at this tread. Share this post Link to post Share on other sites
Josbe 1 Posted January 17, 2005 @Slim: Yes, but only will delete the file.@Muzzikap: Probably, the directory cannot deleted, because it's being handled for FileFindFirstFile(). AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Share this post Link to post Share on other sites
SlimShady 1 Posted January 17, 2005 @Slim: Yes, but only will delete the file.<{POST_SNAPBACK}> @Muzzikap: Probably, the directory cannot deleted, because it's being handled for FileFindFirstFile().<{POST_SNAPBACK}>Possible... Share this post Link to post Share on other sites
Muzzikap 0 Posted January 18, 2005 Possible...<{POST_SNAPBACK}>Thanxz Josbe & Slimshady,Josbe you were right it kept returning an error because it's being handled for FileFindFirstFile().So with a little modification this code works FileClose($Zoek) << added this line if DirRemove ( $dir ) = 0 then MsgBox(0, "why o why dont remove", $dir); Share this post Link to post Share on other sites