1 | initial version |
You can use the command line to remove all files and folders except for one particular subfolder by following these steps:
Open a command prompt or terminal window.
Navigate to the parent directory of the subfolder you want to keep. For example, if your subfolder is located at "C:\parent\subfolder\", navigate to "C:\parent\".
Type the following command and press enter:
rmdir /S /Q directory
Replace directory
with the name of the directory you want to remove, except for your subfolder.
For example, if you have folders named "folder1", "folder2" and "subfolder", and you want to keep "subfolder", you would run the command:
rmdir /S /Q folder1 folder2
Your computer will begin deleting all the files and folders in the specified directory, except for your subfolder.
Note: Make sure you double-check that you have specified the correct subfolder and directories you want to delete before running the command, as it cannot be undone.