Cannot delete a folder con that contains another files

Status
Not open for further replies.

raju9020

Honorable
Dec 5, 2012
1
0
10,510
Hello, i have created one folder with the command prompt named "con" but by mistake i have dropped a folder of mine in that "con" folder. so i am not able to delete folder "con" with the command prompt. which shows error that it "file not empty". suggest me how to delete the folder con by first empting the folder.
 
Solution
If you want to wipe the folder clean you can use robocopy command to overwrite it with an empty folder. Let's say the folder you want to get rid of (with all the files inside) is located at C:\con all you need to do is open elevated command prompt, go back to C:\ root, create a new folder by typing 'MD new' without quotation marks, and then type in 'robocopy /mir C:\new C:\con'.

After doing so, your con folder should be removable by typing 'RMDIR /s /q C:\con' and 'RMDIR /s /q C:\new'

P.S. Be careful though, robocopy is a powerful tool that can wipe your system files if not used with caution, specifically the /mir flag.

Delete the folder beneath the high level folder.
 

Soda-88

Distinguished
Jun 8, 2011
1,086
0
19,460
If you want to wipe the folder clean you can use robocopy command to overwrite it with an empty folder. Let's say the folder you want to get rid of (with all the files inside) is located at C:\con all you need to do is open elevated command prompt, go back to C:\ root, create a new folder by typing 'MD new' without quotation marks, and then type in 'robocopy /mir C:\new C:\con'.

After doing so, your con folder should be removable by typing 'RMDIR /s /q C:\con' and 'RMDIR /s /q C:\new'

P.S. Be careful though, robocopy is a powerful tool that can wipe your system files if not used with caution, specifically the /mir flag.
 
Solution


LOL it is a artifact from the old DOS days. AUX, CON, and several other names have a special meaning to a Microsoft Operating system. For compatibility reasons Microsoft had to keep these names in each generation of OS that they produced.

-Later, Microsoft filtered out the creation of the names from the graphic UI but not from the command prompt. (remove them can break old .bat or cmd files)

Basically, these devices route control to a hardware device and any file extension is ignored. con = console files like con.txt also mean console
others if I remember are AUX, com, lpt, I think there were 8 of them.

-any file with these reserved file names will be sent to the device driver when they are copied, moved. Really screws up poorly written back up files.


you need to rename any folder that is using a reserved name or you will get
"crazy" results. like you copy a file and it goes to your old com (serial port)
rather than where you wanted it to go. or it goes to you con device (screen) in your case.
- it can be a pain to remove the name from the file system. Do yourself a favor and rename the directory before you attempt to remove it with utility.
 
Status
Not open for further replies.