Sign in to follow this  
Followers 0
billgatetlhai

List all directory in C

8 posts in this topic

I want to list all directory in drive C. Who can help me solve my task?

Share this post


Link to post
Share on other sites



_FileListToArray

Share this post


Link to post
Share on other sites

or

FileFindFirstFile() ... go and look it up in the helpfile :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

$hGui = GUICreate("Please Wait... Getting All Directories on drive: " & @HomeDrive, 660, 410, -1, -1)
$List = GUICtrlCreateList("", 5, 5, 650, 400)
GUISetState(@SW_SHOW, $hGui)

$LD = _ListDirectories(@HomeDrive, 1)
$aCnt = StringSplit($LD, "|")
GUICtrlSetData($List,$LD)
WinSetTitle($hGui, "", "Finished... " & $aCnt[0] & " Directories Found on drive: " & @HomeDrive)
$aCnt = 0 

Do
Until GUIGetMsg() = -3

Func _ListDirectories($sPath, $iRecurse = 0, $iDepth = 0)
    Local $hSearch, $sFile, $sFileList
    If Not $iDepth Then 
        Global $sHoldFiles = ''
        If Not FileExists($sPath) Then Return SetError(1, 1, "")
        If Not ($iRecurse = 0 Or $iRecurse = 1) Then Return SetError(2, 0, "")
    EndIf
    If StringRight($sPath, 1) <> "\" Then $sPath &= "\"
    $hSsearch = FileFindFirstFile($sPath & "*")
    If $hSearch = -1 Then Return SetError(3, 0, "")
    While 1
        $sFile = FileFindNextFile($hSsearch)
        If @error Then ExitLoop
        If StringInStr(FileGetAttrib($sPath & $sFile), "D") Then
            If $iRecurse Then _ListDirectories($sPath & $sFile, $iRecurse, $iDepth + 1)
            $sHoldFiles &= $sPath & $sFile & "|"                
        EndIf
    WEnd
    FileClose($hSsearch)
    If Not $iDepth Then
        $sFileList = StringTrimRight($sHoldFiles, 1)
        $sHoldFiles = ""
        Return $sFileList
    EndIf
EndFunc
Edited by smashly

Share this post


Link to post
Share on other sites

dir c: /s /b /ad
:)

Share this post


Link to post
Share on other sites

dir c: /s /b /ad > dir.txt

2x :)

Share this post


Link to post
Share on other sites

That was not the request :party::)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi.

I want to list all directory in drive C. Who can help me solve my task?

Use FileListToArray3.au3 to do so:

#include <filelisttoarray3.au3> ; to be found at http://www.autoitscript.com/forum/index.php?act=attach&type=post&id=18938"]FileListToArray3.au3
#include <array.au3> ; required for _arraydisplay()
$DirArr=_FileListToArray3("C:\","*",2,1) ; BasePath,Pattern,DirsOnly,Recurse
_ArrayDisplay($DirArr)

... depending on the number of files on C: this will take a while!

With that array it's easy to to further operations whatsoever you need to do.

Regards, Rudi.

edit: added comment to $DirArr= line.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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  
Followers 0