Dragon[ITA] |
|
| Ecco un utile e comoda funzione per ottenere la lista dei file nella cartella e in tutte le sottocartelle. Ogni elemento della lista è munito di percorso assoluto o relativo a seconda della variabile path C'è solo 1 parametro: $path che contiene il percorso alla cartella da analizzare. (se è relativo anche i file avranno il percorso relativo) CODICE #cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1 Author: Dragon[ITA]
Script Function: Template AutoIt script.
#ce ----------------------------------------------------------------------------
#include-once #include <File.au3> #include <Array.au3>
Func _GetFileListRecursive($path) Local $i = 0 Local $merge
Local $ret = _FileListToArray($path,"*",1) If Not @error Then For $i = 1 To $ret[0] $ret[$i] = $path&$ret[$i] ;~ MsgBox(0,"1",$ret[$i]) ;DEBUG Next Else Local $ret[1] = [1] EndIf
Local $list = _FileListToArray($path,"*",2) If @error Then Return $ret For $i = 1 To $list[0] $list[$i] = $path&$list[$i]&"\" ;~ MsgBox(0,"2",$list[$i]) ;DEBUG Next
$i = 0 While 1 $i += 1
$merge = _FileListToArray($list[$i],"*",2) If not @error Then For $j = 1 To $merge[0] $merge[$j] = $list[$i]&$merge[$j]&"\" ;~ MsgBox(0,"3",$merge[$j]) ;DEBUG Next _ArrayConcatenate($list, $merge, 1) EndIf
If $i = UBound($list)-1 Then ExitLoop WEnd
For $i = 1 To UBound($list)-1 $merge = _FileListToArray($list[$i],"*",1) If not @error Then For $j = 1 To $merge[0] $merge[$j] = $list[$i]&$merge[$j] ;~ MsgBox(0,"4",$merge[$j]) ;DEBUG Next _ArrayConcatenate($ret, $merge, 1) EndIf Next
$ret[0] = UBound($ret)-1
If UBound($ret) = 0 Then Return SetError(1,0,0) Return $ret EndFunc fatene buon uso
|
| |