Hallo
ich hab noch kein so ein Programm bis jetzt gesehen und da ich noch nicht so lange mit AutoIt zu tun habe, habe ich einfach dieses Werk programmiert:
es schreibt alle Unterordner eines Pfades in eine ini Datei! (Warum ini datei? ich wusste nicht was am besten wäre und darum nam ich die ini datei her da meine überlegungen auf die schnelle keine einfachere lösung fanden :))
ich habe für 30014 Ordner auf meiner C Festplatte mit 26Gb belegten speicher platz in etwa 5,5 Minuten gebraucht, damit alle ordner in die Ini datei geschrieben wurden!
ich hoffe euch gefällt mein script und ich hoffe das es Verbesserungsvorschläge gibt, aber auch etwas Lob
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.6.1
Author: Sturmberger Andreas
Script Function:
Saves the whole foldertree of a drive or folder into an inifile
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $sDelim = "|"
;$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
;If Not FileExists($sPath) Then Return SetError(1, 1, "")
;If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
;If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & $sFilter)
;If @error Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If ($iFlag + @extended = 2) Then ContinueLoop
$sFileList &= $sDelim & $sFile
WEnd
FileClose($hSearch)
;If Not $sFileList Then Return SetError(4, 4, "")
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc
#cs ----------------------------------------------------------------------------
I included the _FileListToArray here and not with #include <file.au3> because it made some troubles!
I simply commented all unneeded comments
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Dim $path = "C:\"
Dim $instance = 0
Dim $inipath = "C:\paths.ini"
Dim $tempfiles
Dim $tempdir
Dim $filescount
Dim $count = 1
$files = _FileListToArray($path, "*", 2) ;saves the first instance into the array
IniWrite ($inipath, "instance " & $instance, "files", $files[0]) ;writes the numbers of containing folders in the root to the ini file
For $i = 1 to $files[0]
IniWrite ($inipath, "instance " & $instance, "path" & $i, $path & $files[$i]) ; writes the path of the folders into the ini file while the first folder is path1, the second path2, the n pathn
Next
Do
$bool = false ;is needed to stop the loop
$instance += 1 ;counts the instance
$tempfiles = IniRead($inipath, "instance " & $instance - 1, "files", "Fehler") ;var which contains the number of the containing folders of the next lower instance
for $i = 1 to $tempfiles ;counts from 1 to the number of the containing folder of the next lower instance
$tempdir = IniRead($inipath, "instance " & $instance - 1, "path" & $i, "Fehler") & "\" ;var which contains the path of the "$i"-folder of the next lower instance
$files = _FileListToArray($tempdir, "*", 2) ;saves the folders of the path of $tempdir
$filescount += $files[0] ;counts how many folders contained in the folder of $tempdir
;Write to inifile
For $j = 1 to $files[0] ; counts from 1 to the number of folders contained in $tempdir
If $files[$j] <> "" Then ;some folders can't be accessed or are simply the last folder of the instance
IniWrite ($inipath, "instance " & $instance, "path" & $count, $tempdir & $files[$j]) ;writes the path of the folders into the ini file while the first folder is path1, the second path2, the n pathn
$count += 1 ;counter so we know which path? is needed
$bool = true ;if there are no more folders to access $bool will stay false and it will end the loop
EndIf
Next
;end write to inifile
Next
IniWrite ($inipath, "instance " & $instance, "files", $count - 1) ;writes the number of folders in the 2nd instance
if $count = 1 Then iniDelete($inipath, "instance " & $instance) ;if the count doest increase it means the last instance was the instance before this 1. so the last distance made has to be deleteg again
$count = 1 ;resets the count to 1
Until $bool = false