Easily find the character length of particular file paths.

Article by Chris Briand, CSWE updated August 29, 2011

Article

Finding the maximum file path length…No matter how far we advance through operating systems or other software, we often bump into a 256 character limit when attempting to copy or archive files.  The end result is our copy and paste sequence telling us that our “File Path length is too long“, or a zip file that seemingly does not include some of the files you had intended.  Errors such as this can appear random, and it is only after a step back and some analysis, can we see that it is a scenario where the length of the file path is the common factor.

What if we could take a look at our directory structure beforehand to see where problems might show up before we go about copying over a complex file structure.

The steps to file path length awareness are below:

  1. Open the Run Dialog from your version of windows and type “CMD” and enter to bring up the command window.
Run dialog

Run dialog

We will use the DIR (Directory) command at the prompt to output a list of all files and sub-folders from the root of our data or storage drive. (Drive letter D:\)

  1. At the command prompt type “dir D:\ /s /b > files.txt” then hit ENTER and wait for the command prompt to return  (This may take a few moments)
Windows Command Window for file path length

Windows Command Window

The prior DIR command has written the file paths for every file on that Hard Drive, out to a text file called “Files.txt”. Some of the other arguments that can be used are as follows.

/S     include all subfolders.
/Q     Display the owner of the file.
/N     long list format where filenames are on the far right.
/B     Bare format (no heading, file sizes or summary)
  1. Find the “files.txt” text file, the DIR command will deposit the file on the root of the C:\ drive.
  2. Open the text file (It may be many MB’s in size and may take some time). Once open, choose CTRL+A to select the entire text within the text file. Once selected use CTRL+C to make a copy of the entire document.
  3. Open a new EXCEL Spreadsheet, and Use CTRL+V to paste the contents of the text document onto the new sheet. Each line of text Should fall onto an individual Row.
  4. In order to sort the entries by the number of characters Add an equation to cell B1 =LEN(A1). This equation will report the correct number of characters contained in each file path if populated down the 2nd column.
  5. Once the list is populated with the second column which should be reporting the character length of all of the rows, sort the list based on the character values listed in Column B.  You should then be able to see clearly where the path lengths increase over 256 characters.

I hope this procedure is as useful for you as it has been for me.

Related Links

Get Certified SOLIDWORKS Services from Javelin

Javelin Experts can help you to:

Posts related to 'Easily find the character length of particular file paths.'

Find Related Content by TAG:

Chris Briand, CSWE

Chris has been educating and supporting Engineers, Designers and IT Personnel within the 3D CAD industry since 2002, and was adopted into the fantastic team of applications experts here at Javelin Technologies in early 2006.  Chris enjoys the continuous learning driven by the ingenuity and challenges Designers bring forward. Innovation using 3D Printing, 3D CAD and other technologies, combined with a diverse background as a technologist, allows Chris to find solutions that accelerate Designers, and take Design Teams to new heights. Chris is currently being held at an undisclosed location, near Halifax, Nova Scotia, Canada.