Is there an easy way to remove a folder and its files and subfolders using wildcards like this:
RMDir /r "c:\folder*"
I know that it can't work with RMDir but I was not able to find any simple solution (otherwise I will have to get the list of all the matching folders and remove them one by one)
Easy way to remove a folder and its files and subfolders using wildcards
10 posts
Doesn't this work?
RMDir /r "c:\folder"
-Stu
RMDir /r "c:\folder"
-Stu
No it is not working, because I have a bunch of folders called
folder1, folder6, folderXXX, and I want to remove all of them without having the complete list, that's why I need to use wildcards.
folder1, folder6, folderXXX, and I want to remove all of them without having the complete list, that's why I need to use wildcards.
How about this:
Use FindFirst/FindNext to get everything in your folder (files and subfolders), then check with DirState that what you have is not a file (the function returns -1 in case you have a file), match some pattern with WordFind (from your post it sounds that all the folders are named FolderXXX, so look for 'Folder') then use RMDir to remove only those folders that match your criteria
Hope this helps
CF
Use FindFirst/FindNext to get everything in your folder (files and subfolders), then check with DirState that what you have is not a file (the function returns -1 in case you have a file), match some pattern with WordFind (from your post it sounds that all the folders are named FolderXXX, so look for 'Folder') then use RMDir to remove only those folders that match your criteria
Hope this helps
CF
You don't need to use DirState. Just check that it's a folder by doing:
IfFileExists $R0\*.* folder notfolder
-Stu
IfFileExists $R0\*.* folder notfolder
-Stu
ok Thanks
One strange thing is that sometimes when I call
RMDir /r my_folder
the content of the folder is deleted (even subfolders), but the folder itself still exists.
It 's not a right problem because I am able to delete the folder from Windows explorer.
But most of the time it is working fine.
One strange thing is that sometimes when I call
RMDir /r my_folder
the content of the folder is deleted (even subfolders), but the folder itself still exists.
It 's not a right problem because I am able to delete the folder from Windows explorer.
But most of the time it is working fine.
were you 'in' the folder with Explorer or anything else at the time? If so, that's why it wouldn't be deleted. Typically this is when an application sets that folder as its' 'working folder', but there can be many causes.
None of these folders were displayed (or opened) during my RMDir call.
I even try to kill my explorer before the call but it doesn't change anything.
I even try to kill my explorer before the call but it doesn't change anything.
How about SetOutPath?
-Stu
-Stu
And if you're still stuck, check out:
It should list whatever processes are touching that folder and preventing you from deleting it.
It should list whatever processes are touching that folder and preventing you from deleting it.