Skip to main content
added 4 characters in body
Source Link

Seems everyone is missing the fact that we're wanting to delete multiple sub folders, but NOT delete the parent folder. We may also no know all the names of the subfolders, and don't want to do each one individually.

So, thinking outside the box, this is how I solved this issue.

mkdir c:\EmptyFolderToBeDeletedSoon Robocopy

Robocopy /Purge c:\EmptyFolderToBeDeletedSoon c:\FolderIWantEmpty rmdir

rmdir c:\EmptyFolderToBeDeletedSoon

Make a temp directory that's empty. Use the RoboCopy command with the /Purge switch (/PURGE :: delete dest files/dirs that no longer exist in source.) using the empty folder as the source, and the folder we want empty as the destination. Delete the empty temp folder we created to be the empty source for Robocopy.

Now, you have an empty folder of all files and folders, which is what this whole string was about.

Seems everyone is missing the fact that we're wanting to delete multiple sub folders, but NOT delete the parent folder. We may also no know all the names of the subfolders, and don't want to do each one individually.

So, thinking outside the box, this is how I solved this issue.

mkdir c:\EmptyFolderToBeDeletedSoon Robocopy /Purge c:\EmptyFolderToBeDeletedSoon c:\FolderIWantEmpty rmdir c:\EmptyFolderToBeDeletedSoon

Make a temp directory that's empty. Use the RoboCopy command with the /Purge switch (/PURGE :: delete dest files/dirs that no longer exist in source.) using the empty folder as the source, and the folder we want empty as the destination. Delete the empty temp folder we created to be the empty source for Robocopy.

Now, you have an empty folder of all files and folders, which is what this whole string was about.

Seems everyone is missing the fact that we're wanting to delete multiple sub folders, but NOT delete the parent folder. We may also no know all the names of the subfolders, and don't want to do each one individually.

So, thinking outside the box, this is how I solved this issue.

mkdir c:\EmptyFolderToBeDeletedSoon

Robocopy /Purge c:\EmptyFolderToBeDeletedSoon c:\FolderIWantEmpty

rmdir c:\EmptyFolderToBeDeletedSoon

Make a temp directory that's empty. Use the RoboCopy command with the /Purge switch (/PURGE :: delete dest files/dirs that no longer exist in source.) using the empty folder as the source, and the folder we want empty as the destination. Delete the empty temp folder we created to be the empty source for Robocopy.

Now, you have an empty folder of all files and folders, which is what this whole string was about.

Source Link

Seems everyone is missing the fact that we're wanting to delete multiple sub folders, but NOT delete the parent folder. We may also no know all the names of the subfolders, and don't want to do each one individually.

So, thinking outside the box, this is how I solved this issue.

mkdir c:\EmptyFolderToBeDeletedSoon Robocopy /Purge c:\EmptyFolderToBeDeletedSoon c:\FolderIWantEmpty rmdir c:\EmptyFolderToBeDeletedSoon

Make a temp directory that's empty. Use the RoboCopy command with the /Purge switch (/PURGE :: delete dest files/dirs that no longer exist in source.) using the empty folder as the source, and the folder we want empty as the destination. Delete the empty temp folder we created to be the empty source for Robocopy.

Now, you have an empty folder of all files and folders, which is what this whole string was about.