How Long is Too Long
There is much confusion and
speculation as to what
constitutes a filename or path that is too
long for Microsoft Windows. 256? 260? 259?
32,000+? 180? 247? 248? The confusion is
understandable since all those - and more -
are correct and they are wrong and they are
sometimes correct and wrong at the same time.
What is a filename
When it comes to names and paths, folders
(directories) and filenames are exactly the same:
all rules that apply to filenames also apply to
folder names. There is a common misconception that
folders don't have extensions (the name after the
dot). But that is just a convention that developed
from the way Microsoft first named most of
Windows' system folders many years ago. Any folder
can have an extension just as any filename can
exist without one. So when I mention filename in
the rest of this post I'm also referring to folder
names unless explicitly stated otherwise.
There are three parts to a full pathname.
- the drive or volume (for example C:\ and \\Server\)
- the path to the file (for example
- the actual filename and optional extension
(for example checklog.db)
Combining all three parts results in a
fully-qualified filename (fully-qualified
meaning that it is uniquely identified by having
all three parts) would be something like
From here on we'll refer to a fully-qualified filename
as a pathname.
The quick and the simple rule of filename
If you want to skip the following explanations
of the (semi-)exact maximum lengths. Just remember
that you really shouldn't create any file with a
total pathname length (drive, path, and filename
and extension) greater than around 230 characters
- and even then much shorter would be better. And
perhaps even more important don't create really
long filenames for as they are copied around the
will easily be copied to folders that already are
long making them exceed the limits that can be
handled by one program or another or even Windows.
For example if you create a filename that 240
characters long, say something like:
Annual report on the average gestation
period of North American pelicans by professor
emeritus…..issued on July thirteenth in the year
two thousand and thirteen…and originally present
to the symposium on….well received.docx
All may go well until the file gets copied to:
will create a pathname in excess of any reasonable
limit and will create problems someone in the
The gory details on maximum filename lengths
Here is where the numbers come from in the
traditional, as in original, Windows file system:
260 – Because there was only
space to store 260 characters for each pathname.
However, this is really only of significance to
systems programmers and numerologists.
259 - Because one of those
bytes had to be a null or 0 at the end of the
string. You can't see this last byte it is just
there so that Windows and Windows programs would
know where the end of the filename was. So that
left only 259 possible characters in the visible,
256 - Because some young,
smart-aleck (who is by now an old, potbellied head
of some insignificant section of a small computer
department somewhere) said, “Well the drive isn't
part of the path name and that is three characters
long (a letter, a colon, and a backslash e.g.,
C:\) so really the maximum length
is 256 characters”. Why anyone listened to that
smart-aleck we don't know but people did and 256
became the number that people who knew little
would utter with a condescending nod indicating they knew a lot
more than that (but of cource, they didn't).
248 - I'll explain this and
the next one but you might just as well forget
them immediately unless you can use them to
impress your boss, your friend or your significant
other. 248 equals 260 minus 12. Brilliant! why
minus 12? Because that was the maximum length of a
filename - 8 characters plus a dot plus a three
character extension. And since a path always had
to have space for a filename to be added to it, it
couldn't be longer than 248 characters. Of course
this is the maximum length of a path without a
filename, which really can't exist by itself.
247 - Same as above except
that the 12 characters for the name is subtracted
from 259 instead of 260 as these people didn't see
and thus didn't know about the trailing 0
(remember those people?).
180 - The approximate maximum
length allowed by some file systems used when
writing to CDs and other round, thin, removable
media. The important thing to note here is that
180 is an approximate number that may vary a bit
from CD to CD for various technical reasons only
understood by those who decided to set the maximum
filename for these devices to 180, approximately.
32,000+ - Available on some
modern versions of Windows and modern file
systems. Don't count on this unless you really
know what you are doing and are not adverse to
experiencing true disaster down the road. Even
when this length is acteive any single element of
the full pathname (the filename itself or any one
folder along the path, still can't be longer than
256 (or less).
And just because really long fully qualified
paths are OK by Windows doesn't mean that other
pograms will be happy with it.
But wait -- it gets worse
The usable maximum pathname length depends not
only on the storage media and version of Windows
but also the programs that will be working with
the file as some programs have smaller limits on
file length and while these are becoming less and
less common they still exist. But was is even
worse is that some Windows functions can't handle
as long pathnames as other parts of Windows so you
may be able to copy a file but not delete it.
We will discuss how to find files with
pathnames long enough to create problems and how
to handle them in a post later this week.
For complete details on how to efficiently find long filenames and rename them click