Jump to content
Sign in to follow this  

my script dont work with most directories script should list all directories and files

Recommended Posts


This script I made don't list most directory's files for example it don't list files in c:\windows\system32, however it lists files in c:\windows\ime, Why this script dont list files in c:\windows\system32 ?

My objective is make script that list all files in directory and if directory have any sub directories then it must also list files in subdirectories.In otherwords I need script that generates full directory tree since given directory,script that reveal whole directory tree.

Edit: code updated, I invented how to list files in system32, but I still need help with making it more dynamic.At the moment sctipt list files like \maindir\subdir\file.ext but directory structure is not fixed, which mean it could also be \maindir\file.ext or \maindir\subdir1\subdir2\N number of directories\file.ext and all these directories may or may not contain files, if directory contain files, files must be added in list.

#include <File.au3>
$alltext = ""
$path = "C:\windows"
$flist = _FileListToArray($path, "*", 2)
For $i = 1 To $flist[0]
    $alltext = $alltext & $path & "\" & $flist[$i] & @CRLF
    $newpath = $path & "\" & $flist[$i]
    $flist4 = _FileListToArray($path & "\" & $flist[$i], "*", 1)
    If Not @error Then
        For $b = 1 To $flist4[0]
            $alltext = $alltext & $path & "\" & $flist[$i] & "\" & $flist4[$b] & @CRLF
    $flist2 = _FileListToArray($path & "\" & $flist[$i], "*", 2)
    If Not @error Then
        For $n = 1 To $flist2[0]
            $alltext = $alltext & $path & "\" & $flist2[$n] & @CRLF
            $flist3 = _FileListToArray($path & "\" & $flist2[$n], "*", 1)
            If Not @error Then
                For $a = 1 To $flist3[0]
                    $alltext = $alltext & $path & "\" & $flist2[$n] & "\" & $flist3[$a] & @CRLF
Edited by E1M1


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.