wolkenloser Posted March 18, 2006 Share Posted March 18, 2006 Hi I ´ve a problem with ten FindFirstFile Command. I will search recursly in a Drive for all path and check the pathlength with Command FindFileNext My Script is already working, but it crashed when the pathlength will be more the 260 characters (why not 255 ?) Here ist the point where the error appears. while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file tooltip($file) You see the "exitLoop" command. If I disabel it, the Script will be stopped and won't continue. It is possible by going another way ? Here the komplet Script (its a changed "Copy with Progressbar", fond in this Forum some Month ago) expandcollapse popup#include <file.au3> #include <Array.au3> #include <GUIConstants.au3> #include <process.au3> Opt("RunErrorsFatal",0) Opt("TrayIconDebug", 1); ;~ $s_Tempdir = _TempFile() ;~ DirCreate($s_Tempdir) $max_count = InputBox("Länge der Pfade prüfen","Bitte länge ab der das Logfile gefüllt werden soll eingeben (max 256)",230) $pfadlaenge_logfile = @tempdir & "\pfadlänge.txt" FileOpen($pfadlaenge_logfile,2) ; GUI Start: GUICreate("Dateilänge Prüfen...",420,100, -1,-1,-1, $WS_EX_TOOLWINDOW ) $progressbar1 = GUICtrlCreateProgress (10,20,400,20) GUICtrlSetColor(-1,32250) $Progress1Text = GUICtrlCreateLabel ( "Überprüfe Dateien: ", 10, 42 , 400 , 20, $SS_LEFTNOWORDWRAP ) $progressbar2 = GUICtrlCreateProgress (10,60,400,20, $PBS_SMOOTH) $Progress2Text = GUICtrlCreateLabel ( "", 10, 82 , 400 , 20, $SS_LEFTNOWORDWRAP ) ;GUISetFont (10, 600, ) $Progress2Text2 = GUICtrlCreateLabel ( "", 150, 62 , 400 , 20 ) GUICtrlSetColor(-1,0x0000ff) GUISetState (@SW_Show) ;Definition der Globals: Global $FileCount = 0 Global $FirstRunCount=0 Global $QtyLeft=0 Global $CountFilesInCurrent=0 Global $Count2 Global $CurrentDirQty Global $Percent2 ;**************************************************************************** ;Hier kann auch schon eine fixe Quelle und ein Ziel gesetzt werden: ;$sOriginalDir = "C:\Windows" ;$sDestDir = "D:\Windows_Backup" ;StartCopy ($sOriginalDir, $sDestDir) ;Quellordner auswählen: $sOriginalDir = FileSelectFolder("Auswählen des Quell-Ordners","",1) ;MsgBox(0,"",$sOriginalDir) if $sOriginalDir = "" then MsgBox(0,"Achtung","Kein Ordner ausgewählt - Bitte nochmal starten") Exit EndIf ;Zielordner auswählen: ;$sDestDir = FileSelectFolder("Auswählen des Ziel-Ordners","",1) $sDestDir = @Tempdir ;Start des Kopiervorganges: StartCopy ($sOriginalDir, $sDestDir) FileClose($pfadlaenge_logfile) _RunDOS("notepad " & $pfadlaenge_logfile) ;***************************************************************************** ;Das dient zur Benutzung über die CMD od. den Ausführen-Dialog: ;Babei müssen allerdings die zwischen den mit * markierten Zeilen entfernt werden! ;Beispiel: ;FileCopy.exe "C:\Windows" "D:\Windows_Backup" If $cmdline[0] = 2 Then $DirSearch = $cmdline[1] $Destination = $cmdline[2] StartCopy ($DirSearch,$Destination) Else ;MsgBox(0,'Invalid # of parameters!',$cmdline[0]&' is an Invalid number of parameters.') ;Exit EndIf Func StartCopy ($Var1, $Var2) If StringRight($Var1, 1) = '\' Then $Var1 = StringtrimRight( $Var1, 1 ) If StringRight($Var2, 1) <> '\' Then $Var2 = $Var2 & '\' $Var3 = $Var1 ;ProgressOn ("Copying Files", " Please Wait: Copying: " , "To ", -1,-1,16 ) SplashTextOn("Dateilänge Prüfen","ANALYE läuft...bitte warten",400,20,10,10) processFolder($Var1, $Var2, $Var3) SplashOff() debug ("Anzahl der zu kopierenden Dateien: " & $FileCount) $QtyLeft = $FileCount $FirstRunCount=1 ProcessFolder ($Var1, $Var2, $Var3) ;ProgressOff() GUICtrlSetData ( $Progress1Text, "fertig" ) GUICtrlSetData ($progressbar2, 100) GUICtrlSetData ( $Progress2Text, "fertig" ) GUICtrlSetData ( $Progress2Text2, "Überprüfen zu 100% beendet") Sleep (1000) EndFunc func processFolder($path, $Destination, $Fixed) local $fileHandle, $file, $dirHandle, $dir local const $FILESPEC = "*.*" debug("Start mit " & $path) $FirstCountFilesInCurrent = 0 $Count2 = 1 debug("Suche nach " & $path & "\" & $FILESPEC) $fileHandle = fileFindFirstFile($path & "\" & $FILESPEC) if ($fileHandle <> -1) then If $FirstRunCount = 1 then Count($Path) endif while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file tooltip($file) if (isFolder($file,$Destination, $Fixed)) then continueLoop copy($file, $Destination, $Fixed) If $FirstRunCount = 0 then $FirstCountFilesInCurrent = $FirstCountFilesInCurrent + 1 wEnd fileClose($fileHandle) endIf debug("Unterordner durchsuchen:") $dirHandle = fileFindFirstFile($path & "\*.*") if ($dirHandle <> -1) then while (1) $dir = fileFindNextFile($dirHandle) if (@error = 1) then exitLoop if ($dir = "." or $dir = "..") then continueLoop $dir = $path & "\" & $dir if (not(isFolder($dir,$Destination, $Fixed))) then continueLoop debug("Unterordner gefunden: " & $dir) processFolder($dir, $Destination, $Fixed) ;$CountFilesInCurrent = 1 $CurrentPercent = 0 wEnd fileClose($dirHandle) endIf endFunc func isFolder($path,$Destination, $Fixed) if stringInStr(fileGetAttrib($path), "D") then $stripped =stringreplace($Path, $Fixed &"\","") ;~ DirCreate ( $Destination & $Stripped ) ;~ debug ("Pfad: " & $Path) ;~ debug ("Verzeichnis erstellen: " & $Destination & $Stripped) return 1 else Endif return 0 endFunc func copy($text,$Destination, $Fixed) $NewDir = $Destination $stripped =stringreplace($text, $fixed &"\","") if $FirstRunCount = 0 then $FileCount = $FileCount + 1 Else Progress ($CurrentDirQty, $Count2) $QtyLeft = $QtyLeft - 1 $Percent = $qtyLeft * 100 / $FileCount $Percent1 = 100 - $Percent $Count2 = $Count2 + 1 ;ProgressSet ( $Percent1 + 1 ,"Copying " & $text & @CRLF & @CRLF & "To " & $NewDir & $Stripped , " Please Wait: " ) $aWholeNumber2 = StringSplit( $Percent2, "." ) ;_arrayDisplay ( $aWholeNumber2, "") GUICtrlSetData ( $Progress1Text, $aWholeNumber2[1] & "% des aktuellen Ordners:- " & $Stripped ) $aWholeNumber = StringSplit( $Percent1, "." ) ;_arrayDisplay ( $aWholeNumber, "") GUICtrlSetData ($progressbar2,$Percent1) GUICtrlSetData ( $Progress2Text, $NewDir & $Stripped ) GUICtrlSetData ( $Progress2Text2, "Gesammt beendet: " & $AWholeNumber[1] & "%" ) ;####DETLEF ;FileCopy ($text, $NewDir & $Stripped,1) $pfadlaenge = FileGetLongName ($text) $pfadlaenge_count = StringLen($pfadlaenge) if $pfadlaenge_count >$max_count then FileWriteLine($pfadlaenge_logfile,"[" & $pfadlaenge_count & "];" & $pfadlaenge) ;Tooltip($pfadlaenge) Endif endFunc Func Count($Dir) local $fileHandle, $File, $Path, $Destination , $Fixed, $Count2 $fileHandle = fileFindFirstFile($Dir & "\" & "*.*") if ($fileHandle <> -1) then while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file $Count2 = $Count2 + 1 wend fileClose($FileHandle) Endif $CurrentDirQty = $Count2 Endfunc func debug($text) ;If $FirstRunCount = 1 then msgBox(0x40, "", $text) endFunc Func Progress($CurrentDirQty, $Count2 ) $QtyLeft2 = $Count2 + 1 $QtyLeft2 = $QtyLeft2 - 1 $Percent2 = $qtyLeft2 * 100 / $CurrentDirQty GUICtrlSetData ($progressbar1,$Percent2) EndFunc greetings Wolke Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now