In order to delete a too-long-file, all you need to do is open a command prompt in the directory where the file is located and use a simple command to get the short file name. Open File Explorer and navigate to the directory where your files are located. Press and hold Shift, then right-click on an empty area. Choose “Open command window here”. A Command Prompt window will open, focused on the directory you’re in.
Then, enter the following command in the Command Prompt window:
DIR /X
If the directory contains more files than can be displayed on a single screen, use the command DIR /X /P
instead, so that it will pause at every screen length so you can examine the file list.
This command will list all the directories and files in the current directory, and it will also list the old 8.3 filename for all the files and directories. In our example screenshot above, you can see how the dummy txt file with nonsensical (and hundreds of characters long) filename is reduced to a simple “WHYSOL~1.TXT”.
Armed with the short name of the file or directory you wish to delete, you can simply issue a DEL command for the file:
DEL WHYSOL~1.TXT
Obviously, replace WHYSOL~1.TXT
with the name of the file you want to delete.
Windows will delete the file without complaint (you can run DIR /X
again to confirm or just check the directory in Window Explorer). That’s all there is to it! With a clever use of a very old command, you can delete any file regardless of how long the file name is.
However in some cases the command prompt does not show the sortname of the file, of course you van guess what is was supossed to be, but when there is only one, or all files in the current directory must be deleted anyway, you can use the command: del .