Discussion Locked

remove com1 directory

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Do you have any idea how to remove a directory called com1. I have tried all the standard tools, because the file is named a windows reserved name "com1" that normal tools do not work.

del \\.\e:\ftp\com1 does not work. ::: bypass checking for reserved filenames

rm com1 does not work. ::: rm.exe is a posix utility.

Any ideas?

3 replies

by maxwell edison

If the file was created on a file allocation table (FAT) partition, you may be able to delete it under MS-DOS using standard command line utilities (such as DEL) with wildcards. For example:

DEL PR?.* -or- DEL LPT?.*

These commands do not work on an NTFS partition as NTFS supports the POSIX subsystem and filenames such as PRN are legal under this subsystem. However, the operating system assumes the application that created them can also delete them; therefore, you can use commands native to the POSIX subsystem.

You can delete (unlink) these files using a simple, native POSIX application. For example, the Windows Resource Kit includes such a tool, Rm.exe.

NOTE : POSIX commands are case sensitive. Drives and folders are referenced differently than in MS-DOS. Windows 2000 and later POSIX commands must use the following usage syntax:
posix /c [] IE: posix /c c:\rm.exe -d AUX.

Usage assumes Rm.exe is either in the path, or the current folder:

rm -d // driveletter/ path using forward slashes / filename

For example, to remove a file or folder named COM1 (located at C:\Program Files\Subdir in this example), type the following command:

rm -d "//C/Program Files/Subdir/COM1"

To remove a folder and itsentire contents (C:\Program Files\BadFolder in this example), type the following command:

rm -r "//C/Program Files/BadFolder"

Another option is to use a syntax that bypasses the normal reserve-word checks altogether. For example, you can possibly delete any file with a command such as:

DEL \\.\ driveletter :\ path \ filename
For example:

DEL \\.\c:\somedir\aux

Good luck,

Maxwell

This discussion is closed to new replies.