Pinterest Stumbleupon Whatsapp
Advertisement

“Please help. I can’t delete a file due to the filename being too long.”

This one is a perplexing problem that can be solved in five seconds, and all it takes is a simple DOS command from the past. But first, let’s get introduced to one of the oldest errors that Windows throws up and the culprit behind them: Long Filenames (LFN).

What Are Long Filenames?

Long Filenames are inherited from Windows 95 and its MS-DOS architecture. The LFN system specified file and directory names of up to 255 characters. This was a change from the older 8.3 file naming convention of a maximum eight characters (after any directory path), followed optionally by a filename extension consisting of a period [.] and at most three more characters.

As Windows is backwards compatible, we will use this “interconversion” between the two file naming systems to solve our problem, because sometimes filenames will exceed the limits set for them.

Many Windows programs expect the maximum path length to be shorter than 255 characters. This limit excludes the file path under which it is located. But, when you copy a file from one location, it takes into account the entire file path.

Long File Name

Advertisement

Files with too long filenames can be a product of other operating systems. It can also be born as a cache file from a third-party software. Or, it can be a media file with a really long name. Sometimes, these files are also created if they exist in deeper directories like a network share.

You can manage such files with the software that created them. But if that fails, here’s a much easier solution.

Solving “Too Long” Filename Errors

It is a simple three-step process to delete a file with a long filename. The trick is to auto-generate a shorter filename and use that.

  1. Open a command prompt in the directory where the file is located.
  2. Use a DOS command to get the short filename in the 8.3 filename format.
  3. Now, use the DEL command in DOS for the file to delete the file.

Let’s see how it works with an example. Here we have a file with a long filename in a directory.

Open File Explorer and browse to the file in its directory. Press Shift and then right-click on an empty area. Choose Open command window here. A Command Prompt window will open with the path set to the directory you’re in.

Open Command Prompt

Enter the DOS command for listing the files and folders in the current directory. The dir command is an internal command and is available on all Microsoft operating systems. The /X attribute displays the short names for non-8.3 filenames. You can also use DIR /X /P to pause and move from one screen to the next when there are too many files to examine.

The screenshot below shows you the text file we want to delete with the “modified” short filename.

So, you can see how we used DOS to “auto-generate” a shorter name for the file. Now, just use the simple DEL command on the short filename to remove the file. That’s it!

The lesson here is to not neglect DOS. There are a variety of useful DOS commands The 8 Useful DOS Commands That You Should Memorize The 8 Useful DOS Commands That You Should Memorize Windows 7 still features a command prompt window. so there's still a place for DOS commands. So for those of you that like the idea of typing in a few commands to avoid the hassle of... Read More that can still save your day.

Have you come across the problem of too long filenames? What is the approach you used?

Image Credit: hanss via Shutterstock.com

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. morgancooper
    May 7, 2017 at 10:54 am

    Long PathTool is a software that will let you easily delete, copy or rename long path files.

  2. cris
    January 18, 2017 at 9:28 am

    this just shows that DOS is still useful until now.

    • Saikat Basu
      January 22, 2017 at 6:10 am

      Very much so. I think it is one of the "geek" skills everyone should learn a little.