Raymond Posted June 19, 2006 Share Posted June 19, 2006 Is there any simple way to delete all files and subfolders recursively under specific folder (but I wanna keep this folder)? DirRemove can only delete one subfolder at a time and you have to give it the subfolder name. So many subfolders there... Plus, FileSetAttrib("C:\Documents and Settings\xx\Favorites\", "-R") DirMove("C:\Documents and Settings\xx\Favorites\", 1) got a msg saying "Favorites is a Windows system folder and is required for Windows to run properly. It cannot be deleted." How can I get over with it? My system is win2kpro sp3. Thanks for your help in advance. Link to comment Share on other sites More sharing options...
Briegel Posted June 19, 2006 Share Posted June 19, 2006 Is there any simple way to delete all files and subfolders recursively under specific folder (but I wanna keep this folder)? DirRemove can only delete one subfolder at a time and you have to give it the subfolder name. So many subfolders there... Plus, FileSetAttrib("C:\Documents and Settings\xx\Favorites\", "-R") DirMove("C:\Documents and Settings\xx\Favorites\", 1) got a msg saying "Favorites is a Windows system folder and is required for Windows to run properly. It cannot be deleted." How can I get over with it? My system is win2kpro sp3. Thanks for your help in advance. Use latest Beta and try this ... #Include <File.au3> #Include <Array.au3> $sPath = "C:\Documents and Settings\XXX\Favoriten" FileDelete($sPath & "\*.*") $folderlist = _FileListToArray($sPath, "*", 2) For $i = $folderlist[0] To $folderlist[1] Step -1 DirRemove($sPath & "\" & $folderlist[$i], 1) Next Link to comment Share on other sites More sharing options...
Nomad Posted June 19, 2006 Share Posted June 19, 2006 Is there any simple way to delete all files and subfolders recursively under specific folder (but I wanna keep this folder)? DirRemove can only delete one subfolder at a time and you have to give it the subfolder name. So many subfolders there... Plus, FileSetAttrib("C:\Documents and Settings\xx\Favorites\", "-R") DirMove("C:\Documents and Settings\xx\Favorites\", 1) got a msg saying "Favorites is a Windows system folder and is required for Windows to run properly. It cannot be deleted." How can I get over with it? My system is win2kpro sp3. Thanks for your help in advance. Have you tried: ;full path to folder and * as a wildcard to delete all files contained within FileDelete("C:\Documents and Settings\xx\Favorites\*") Nomad Link to comment Share on other sites More sharing options...
Nomad Posted June 19, 2006 Share Posted June 19, 2006 Use latest Beta and try this ... #Include <File.au3> #Include <Array.au3> $sPath = "C:\Documents and Settings\XXX\Favoriten" FileDelete($sPath & "\*.*") $folderlist = _FileListToArray($sPath, "*", 2) For $i = $folderlist[0] To $folderlist[1] Step -1 DirRemove($sPath & "\" & $folderlist[$i], 1) Next This way also deletes any folders contained within the directory, my way will not. I don't know of a good way to do this if you don't have beta. Link to comment Share on other sites More sharing options...
Briegel Posted June 19, 2006 Share Posted June 19, 2006 Have you tried: ;full path to folder and * as a wildcard to delete all files contained within FileDelete("C:\Documents and Settings\xx\Favorites\*") Nomad @Nomad what about the subfolders? Link to comment Share on other sites More sharing options...
Raymond Posted June 19, 2006 Author Share Posted June 19, 2006 Thanks all replies! Actually I wanna delete all files and subfolders. Now I found a simple way Run(@ComSpec & " /k rd /s /q " & '"C:/Documents and Settings/xx/Favorites\"', "", @SW_HIDE) Copy "/k" switch from Help, honestly I don't know what it means. Link to comment Share on other sites More sharing options...
w0uter Posted June 19, 2006 Share Posted June 19, 2006 /k (Keep) keeps the window open. in your way it should be /c (close) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll 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