Sign in to follow this  
Followers 0
Raymond

Problems with delete folders

7 posts in this topic

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.

Share this post


Link to post
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

Share this post


Link to post
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


Share this post


Link to post
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.


Share this post


Link to post
Share on other sites

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

@Nomad

what about the subfolders?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0