Emiel Wieldraaijer Posted July 18, 2007 Posted July 18, 2007 Is it possible to remove all files and subfolder but not the folder itself ? c:\deleteme c:\deleteme\1 c:\deleteme\2 c:\deleteme\3 c:\deleteme\4 DirRemove ("c:\deleteme", 1) delete also c:\deleteme Thnx Emiel Best regards,Emiel Wieldraaijer
ChrisL Posted July 18, 2007 Posted July 18, 2007 (edited) Is it possible to remove all files and subfolder but not the folder itself ? c:\deleteme c:\deleteme\1 c:\deleteme\2 c:\deleteme\3 c:\deleteme\4 DirRemove ("c:\deleteme", 1) delete also c:\deleteme Thnx Emiel Cant you just recreate it after? DirRemove ("c:\deleteme", 1) DirCreate("c:\deleteme") Edited July 18, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Emiel Wieldraaijer Posted July 18, 2007 Author Posted July 18, 2007 Yeah i could.. but i don't want to .. In the help DirRemove ( "path" [, recurse] )Parameterspath Path of the directory to remove. recurse [optional] Use this flag to specify if you want to delete sub-directories too. 0 = (default) do not remove files and sub-directories -> if this is default why not remove the DirRemove command ??????? 1 = remove files and subdirectories (like the DOS DelTree command) Best regards,Emiel Wieldraaijer
ChrisL Posted July 18, 2007 Posted July 18, 2007 (edited) Yeah i could.. but i don't want to .. Oh OK, hows this then? Clean ("c:\deleteme") Func Clean($current) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") Then FileDelete ($current & "\" & $file) EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") Then DirRemove ($current & "\" & $file,1) EndIf WEnd FileClose($search) EndFunc Oh and this 0 = (default) do not remove files and sub-directories -> if this is default why not remove the DirRemove command ??????? Is so that if the Directory is not empty it doesn't get deleted, 1 forces it to delete even if it's not empty Edited July 18, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
pixels75 Posted July 18, 2007 Posted July 18, 2007 Yeah i could.. but i don't want to .. In the help DirRemove ( "path" [, recurse] ) Parameters path Path of the directory to remove. recurse [optional] Use this flag to specify if you want to delete sub-directories too. 0 = (default) do not remove files and sub-directories -> if this is default why not remove the DirRemove command ??????? 1 = remove files and subdirectories (like the DOS DelTree command) Func Flush($folder) Local $search, $file, $attrib $search = FileFindFirstFile($folder & "\*.*") If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($folder & "\" & $file) If StringInStr($attrib, "D") Then DirRemove($folder & "\" & $file) Else FileDelete($folder & "\" & $file) EndIf Wend EndIf EndFunc
Emiel Wieldraaijer Posted July 18, 2007 Author Posted July 18, 2007 (edited) thnx guys@pixels75 you forgot to mention DirRemove($folder & "\" & $file, 1) Edited July 18, 2007 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer
pixels75 Posted July 18, 2007 Posted July 18, 2007 thnx guys@pixels75 you forgot to mention DirRemove($folder & "\" & $file, 1)You're right ! I've done that quickly
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