• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

File Length Query

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.
0
Rizzle
Asked:
Rizzle
1 Solution
 
Brad GrouxCommented:
The maximum length allowed for full network or storage paths is 260 characters - http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
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 - http://www.softpedia.com/get/System/File-Management/Path-Length-Checker.shtml

Please note, I've never used this tool so your mileage may vary.
0
 
Spike99On-Site IT TechnicianCommented:
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.
0
 
Brad GrouxCommented:
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
zulazenCommented:
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:

$path.length

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

0
 
Spike99On-Site IT TechnicianCommented:
Brad,

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
0
 
RizzleAuthor Commented:
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now