Someone posted this program on one of the forums.. maybe Windows 7 forum. I just modified it to accept larger numbers for the length of path to search for. I think what you are running into is Explorer will not let you go over 260 characters or so, for the total path. I've tested creating empty folders and it gets to the point I can't even click down into them. But programs can create files with much longer paths than Explorer wants to play with(probably because of its ANSI origins.) So you run into the situation Explorer doesn't even recognize the file path as valid, much less let you move or delete it.
Anyway, this program searches your system for paths longer than whatever you enter in the InputBox.
#cs
===== pseudo-code start =====
if parameters exist then parse command-line
check data - terminate if;
1) path not found - exit(1)
2) length not in range - exit(2)
if parameters don't exist or misconfigured then get data from user
initialize output file
scan path recursively, if TLP found then write to output file
if used gui then display output file
if TLP found then exit(3) else exit(0)
===== pseudo-code end =====
#ce
; hide tray icon
#NoTrayIcon
; initialize
Global $AppVer='1.2'
Global $clUsed=False
Global $ScanAllDrives=False
Global $path=''
Global $threshold=0
Global $LogFileName='TLPD-log.txt'
Global $TLPfound=False
; get parameters
If $CmdLine[0]=2 Then
; parse command-line
$clUsed=True
$path=InjectEnvVars($Cmdline[1])
If $path='*' Then $ScanAllDrives=True
If Not $ScanAllDrives And Not FileExists($path) Then
MsgBox(16,'TLPD Error','Path not found !')
Exit(1)
EndIf
$threshold=Int($Cmdline[2])
If $threshold<3 Or $threshold>255 Then
MsgBox(16,'TLPD Error','Invalid threshold !')
Exit(1)
EndIf
Else
; get from user
$result=MsgBox(35,'TLPD Starting','Check all drives ?'&@CR&@CR&'Click [No] to select a specific path to check. ')
Switch $result
Case 2 ; cancel
Exit(9)
Case 6 ; yes
$path='*'
$ScanAllDrives=True
Case 7 ; no
Do
$path=FileSelectFolder('Select path for TLPD to check. Note: select VALID PATH only, or this window will pop up again!','')
If @error=1 Then Exit(9)
Until FileExists($path)
EndSwitch
Do
$threshold=InputBox('Threshold:','Type the maximum threshold of full path length you wish to check for.'&@CR&@CR&'System default is 255 characters, it''s recommended you use lower threshold.',200)
If @error=1 Then Exit(9)
$threshold=Int($threshold)
Until $threshold>3 And $threshold<256
EndIf
; start logging
$LogFile=FileOpen(@TempDir&'\'&$LogFileName,2)
FileWriteLine($LogFile,'=== TLPD (Too Long Paths Detector) Log ===')
FileWriteLine($LogFile,'')
FileWriteLine($LogFile,'Parameters:')
FileWriteLine($LogFile,'path: '&@TAB&@TAB&$path)
FileWriteLine($LogFile,'threshold: '&@TAB&$threshold)
FileWriteLine($LogFile,'')
FileWriteLine($LogFile,'Results:')
FileWriteLine($LogFile,'Length'&@TAB&'Full name')
; eliminate trailing backslash
If StringRight($path,1)='\' Then $path=StringTrimRight($path,1)
; re-show tray icon if in GUI mode
If Not $clUsed Then
Opt("TrayIconHide",0)
TraySetToolTip('TLPD '&$AppVer)
EndIf
; recourse path
If Not $ScanAllDrives Then
check($path)
Else
For $DriveLetter=Asc('A') To Asc('Z')
check(Chr($DriveLetter)&':')
Next
EndIf
; finish Log
FileWriteLine($LogFile,'')
If Not $TLPfound Then FileWriteLine($LogFile,'too long path names were not found.')
FileWriteLine($LogFile,'=== TLPD finished ===')
FileWriteLine($LogFile,'')
FileWriteLine($LogFile,'TLPD version '&$AppVer)
FileWriteLine($LogFile,'TLPD was developed as a complementary product for the EVACopy project:')
FileWriteLine($LogFile,'http://evacopy.sourceforge.net')
FileClose($LogFile)
; if gui was used, display the log
If Not $clUsed Then ShellExecute(@TempDir&'\'&$LogFileName)
; exit
If $TLPfound Then
Exit(3)
Else
Exit(0)
EndIf
Func InjectEnvVars($MyString)
Local $startpoint
Local $endpoint
Local $EnvVar
;repeat this until MyString has no couples of % signs
While StringInStr($MyString,'%',0,2)>0
;find 1st occurnce of %
$startpoint=StringInStr($MyString,'%',0,1)
;find 2nd occurnce of %
$endpoint=StringInStr($MyString,'%',0,2)
;extract string between 1st and 2nd % signs
$EnvVar=StringMid($MyString,$startpoint+1,$endpoint-$startpoint-1)
;replace env var with its value
$MyString=StringReplace($MyString,'%'&$EnvVar&'%',EnvGet($EnvVar))
WEnd
Return $MyString
EndFunc
Func check($path)
; set-up file pass
$search = FileFindFirstFile($path&'\*')
; start file pass
While True
; get next file
$file = FileFindNextFile($search)
; check for end of files in current folder
If @error Then ExitLoop
; check for too long path name
If StringLen($path&'\'&$file)>$threshold Then
FileWriteLine($LogFile,StringLen($path&'\'&$file)&@TAB&$path&'\'&$file)
$TLPfound=True
EndIf
; if directory then recourse
Local $attrib = FileGetAttrib($path&'\'&$file)
If StringInStr($attrib,'D') Then check($path&'\'&$file)
WEnd
; Close the search handle
FileClose($search)
EndFunc