How to Find the longest pathname on a server?

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.
tsi_adminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NJComputerNetworksCommented:
could use

dir /ad /s

to show you the directories...  

Map a drive to the share...then run

dir /ad /s

0
NJComputerNetworksCommented:
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
tsi_adminAuthor Commented:
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
David LeeCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.