Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Scan folders and subfolders and list files only

$
0
0
I found here the following code.
In the array are listed all folders and files.
How to modify the code that the names of the subfolders are not listed.
The path of the file is fine, there the subfolder can be displayed.



[ autoit ]         
#include #Include Local $aRetArray Local $path = "D:\tmp" Local $sFindFile = "*" Local $sRet ;$aRetArray = _FindPathName($path, $sFindFile) ;_ArrayDisplay($aRetArray) $sRet = "" $aRetArray = _FindPathName($path, $sFindFile) _ArrayDisplay($aRetArray) ; Funktion Func _FindPathName($sPath, $sFindFile) Local $sSubFolderPath, $iIndex, $aFolders, $search,$aFoldersSubs $search = FileFindFirstFile($sPath & "\" & $sFindFile) $aFolders = _FileListToArray($sPath, "*", 2) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop Else $sRet &= $sPath & "\" & $file & "|" EndIf WEnd FileClose($search) For $iIndex = 1 To $aFolders[0] $sSubFolderPath = $sPath & "\" & $aFolders[$iIndex] $aFoldersSubs = _FileListToArray($sSubFolderPath, "*", 2) If IsArray($aFoldersSubs) Then _FindPathName($sSubFolderPath, $sFindFile) Next Return StringSplit(StringTrimRight($sRet,1), "|") EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>