Warning before they've nested a file too deep

B

Boe

I believe the issue is that a folder is more than 255 characters in entire
depth of the folder name e.g. c:\user info\templates for 2007\client
templates\master library....
and Windows pretty much won't let you copy files there etc. Is there a way
to have a 2003 R2 server to scans to make sure folders aren't beyond a
certain length?

Thanks
 
O

Olaf Engelke [MVP Windows Server]

Hello,
"Boe" <boe_d@hotmail.com> schrieb im Newsbeitrag
news:eeBzUNy1HHA.5796@TK2MSFTNGP05.phx.gbl...
>I believe the issue is that a folder is more than 255 characters in entire
>depth of the folder name e.g. c:\user info\templates for 2007\client
>templates\master library....
> and Windows pretty much won't let you copy files there etc. Is there a
> way to have a 2003 R2 server to scans to make sure folders aren't beyond a
> certain length?
>

it's 260 chars, and it's annoying, The problem isn't in NTFS, but in the
Windows Explorer. (Some applications are able to create deeper pathes, and a
mapped network drive, which is settled on a share located deep in the
servers directory structure already, will give the clients explorer the same
depth again on top.
AFAIK there is no way with current Windows Server releases to get a warning
ahead.
(Better would be to lift the limit on the Windows Explorer, but this can
only be done by Microsoft, or have the users using less word rich folder and
file names.)
Best greetings from Germany
Olaf
 
P

Pegasus \(MVP\)

"Boe" <boe_d@hotmail.com> wrote in message
news:eeBzUNy1HHA.5796@TK2MSFTNGP05.phx.gbl...
>I believe the issue is that a folder is more than 255 characters in entire
>depth of the folder name e.g. c:\user info\templates for 2007\client
>templates\master library....
> and Windows pretty much won't let you copy files there etc. Is there a
> way to have a 2003 R2 server to scans to make sure folders aren't beyond a
> certain length?
>
> Thanks
>


You can use the Task Scheduler to run the batch file below once every
night to scan your folders. Set "Limit" to whatever value you think is
reasonable, e.g. 230, 240 or 250.

Invoke the batch file with the name of the drive or folder you wish to
scan, e.g. like so:

c:\PathLength.bat d:\

@echo off
set Limit=240
if not %1]==] set Folder=%1

echo> c:\LongPath.vbs Option Explicit
echo>> c:\LongPath.vbs Dim objArgs, ObjFSO, objStream, ObjFldr, ObjWshShell,
ObjExec
echo>> c:\LongPath.vbs Dim StdOut, ComSpec, Folder, line, L, Max, MaxLine
echo>> c:\LongPath.vbs Set ObjFSO =
CreateObject("Scripting.FileSystemObject")
echo>> c:\LongPath.vbs Set ObjWshShell =
WScript.CreateObject("WScript.Shell")
echo>> c:\LongPath.vbs Set objArgs = WScript.Arguments
echo>> c:\LongPath.vbs Set StdOut = WScript.StdOut
echo>> c:\LongPath.vbs Folder = ObjFSO.GetAbsolutePathName(objFldr)
echo>> c:\LongPath.vbs If objArgs.Count ^> 0 Then Folder = objArgs(0)
echo>> c:\LongPath.vbs ComSpec =
ObjWshShell.Environment("PROCESS")("ComSpec")
echo>> c:\LongPath.vbs Set ObjExec = ObjWshShell.Exec(ComSpec ^& " /c dir /s
/b " ^& """" ^& Folder ^& """")
echo>> c:\LongPath.vbs Max=0
echo>> c:\LongPath.vbs line = ObjExec.StdOut.ReadLine
echo>> c:\LongPath.vbs While Len(line) ^> 0
echo>> c:\LongPath.vbs L = Len(line)
echo>> c:\LongPath.vbs if L ^> %Limit% then WScript.Echo(L ^& " " ^& line)
echo>> c:\LongPath.vbs if L ^> Max then
echo>> c:\LongPath.vbs Max = L
echo>> c:\LongPath.vbs MaxLine = line
echo>> c:\LongPath.vbs end if
echo>> c:\LongPath.vbs line = ObjExec.StdOut.ReadLine
echo>> c:\LongPath.vbs Wend
echo>> c:\LongPath.vbs WScript.Echo("")
echo>> c:\LongPath.vbs WScript.Echo("Longest Folder + File:")
echo>> c:\LongPath.vbs WScript.Echo(Max ^& " " ^& MaxLine)
cscript //nologo c:\LongPath.vbs %Folder%
del c::\LongPath.vbs
 
Back
Top Bottom