sksbir Posted October 6, 2005 Share Posted October 6, 2005 How can I delete all the folders and files in a folder, without deleteing the folder itself.I have juste wrote a recursive function witch can do what you want : take a look here.Use the function like this:epur_repertoire($FOLDERTOCLEAR,-1,0) Link to comment Share on other sites More sharing options...
jefhal Posted October 6, 2005 Share Posted October 6, 2005 He already has code to do what he wants (see my very simple code above), but I think he's left the forum. Your code looks like it might be more than he needs, as you have added a lot of very good flexibility for other situations... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
sksbir Posted October 6, 2005 Share Posted October 6, 2005 .....(see my very simple code above)....I have taken a look at it.... and discover a function : StdoutRead() .. seems very interesting, for example retrieving output from WSH script execution thru cscript.exe...I will take a closer look tomorrow. (it's time to go bed here... ) Link to comment Share on other sites More sharing options...
MattX Posted October 7, 2005 Share Posted October 7, 2005 Not sure if this would help you - I did this [ with the help from Larry ] a while back. It will delete all the files / folders from a dir but will ignore anything thats in the 'keep me' dir. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error <> 0 Then ExitLoop If $file = "keep me" Then ContinueLoop If $file = "." Or $file = ".." Then ContinueLoop If StringInStr(FileGetAttrib(@SCRIPTDIR & "\" & $file) , "D") Then DirRemove($file, 1) Else FileDelete(@SCRIPTDIR & "\" & $file) EndIf WEnd FileClose($search) 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