Jump to content

Problems with delete folders


Recommended Posts

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

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

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 :D

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...