File Length Query

Posted on 2014-08-21
Last Modified: 2014-08-26
Hi Guys

Is there a way of running a report or using a tool which will tell a user which files are about the exceed the Windows Maximum file length. Reason i'm asking is a user has just had an issue where she couldn't open or move a file due to its name being too big and they want to mitigate this before it happens again.
Question by:Rizzle
    LVL 14

    Accepted Solution

    The maximum length allowed for full network or storage paths is 260 characters -
    Maximum Path Length Limitation
    In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character.

    As far as I know there isn't any PowerShell command or Windows integrated tool that will allow you to check for the current length. However there is a stand-alone freeware tool that may be of some help -

    Please note, I've never used this tool so your mileage may vary.
    LVL 16

    Expert Comment

    When I want to see if a path is getting close to the path name limit, I copy & paste the full folder path into a blank Word document (I use Word 2010),  then I click on the Review tab.  Under the Proofing section of the Review tab, click on the "Word Count" button: that will tell you the number of characters with & without spaces.

    In Word 2003 & earlier, I think you could find that Word Count item under the Tools menu.
    LVL 14

    Expert Comment

    by:Brad Groux
    Word actually just gives you the word count in the bottom left of the screen and has since Word 2007, opposite the zoom controls. If you don't see it by default you may have turned off the feature somehow. D--Temp-Words.png
    LVL 2

    Expert Comment

    Here's how you can check the length in powershell for a file or path:

    First, create a variable in powershell:

    $path = c:\windows\system32\drivers\etc\hosts

    Open in new window

    Then, find the length of your variable:


    Open in new window

    If you would like to script this to check all the files in a directory, try this:

    $files = gci c:\windows\system32\drivers\etc | select -ExpandProperty name
    foreach($file in $files){
    $filelength = $file.length
    echo "$file, $filelength"

    Open in new window

    LVL 16

    Expert Comment


    I wasn't talking about the word count displayed in the status bar at the bottom: there is no way that I know of to make that display the character count.

    To see the full word & character count, paste the path of the file into Word. Then, click on the "Review" tab and then click on the "Word Count" button to see the full Word Count statistics. This will include the number of characters with & without spaces. This is a screenshot from a full Word document, so the count is way over the path name limit, of course:

    Screenshot of the Word Count dialog in Word 2010
    LVL 13

    Author Comment

    I will try your suggestions and let you know guys :), but due to the amount of files and folders the word document one wouldnt be the best solution.

    Featured Post

    Promote certifications in your email signature

    Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

    Join & Write a Comment

    INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
    A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now