?
Solved

How to Find the longest pathname on a server?

Posted on 2006-04-19
4
Medium Priority
?
1,921 Views
Last Modified: 2012-06-21
I have a fileserver running Windows 2003 server. I know there is a limit on the length of the path there can be. Files start getting hosed up and everything just gets ugly. Is there a way on a server or computer to determine the longest pathname for a group of folders without having to look manually?

pathname  example: //folder1/folder2/folder3/folder4/folder5/file.doc

Thanks

A.M.
0
Comment
Question by:tsi_admin
  • 2
4 Comments
 
LVL 33

Expert Comment

by:NJComputerNetworks
ID: 16489426
could use

dir /ad /s

to show you the directories...  

Map a drive to the share...then run

dir /ad /s

0
 
LVL 33

Expert Comment

by:NJComputerNetworks
ID: 16489443
or go to the root:

dir /ad /s  >>c:\temp\directories.txt

Then open the directories.txt file using excel... you should be able to see the bigger directories here...

use dir /s to see the files too if you want.

0
 

Author Comment

by:tsi_admin
ID: 16511555
Thanks for the response, I tried the above, however it only gives the directory name, I need the number of characters of the entire path.

Thanks,

A.M.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 1500 total points
ID: 16567209
We can do it with a script like the one below.  Follow these instructions to use it.

1.  Copy the script and paste it into Notepad.
2.  Save the file with a .vbs extension.
3.  Go to a command prompt or click Start->Run and enter the following command:
    wscript scriptname.vbs C:\SomeStartingPath    (replace scriptname with the name of the script file)

The script will display the longest path name and its length.

Dim strRootFolder, strLongestPath, intLength, objFSO
Set strRootFolder = WScript.Arguments(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
strLongestPath = ""
intLength = 0
ProcessFolder strRootFolder
Set objFSO = Nothing
WScript.Echo "The longest path name is: " & strLongestPath & vbCrLf & "Length = " & intLength
WScript.Quit

Sub ProcessFolder(strPathname)
      Dim objFolder, objSubFolder, objFile
      Set objFolder = objFSO.GetFolder(strPathname)
      For Each objFile In objFolder.Files
            If Len(objFile.Path) > intLength Then
                  strLongestPath = objFile.Path
                  intLength = Len(strLongestPath)
            End If
      Next
      For Each objSubFolder In objFolder.SubFolders
            ProcessFolder objSubFolder.Path
      Next
      Set objFile = Nothing
      Set objSubFolder = Nothing
      Set objFolder = Nothing
End Sub
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

807 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