Sign in to follow this  
Followers 0
ConsultingJoe

An Other Directory to Txt Writer

2 posts in this topic

This goes 3 levels deep. And for some reason it won't do too many files like the windows directory but it works well.

$folder = FileSelectFolder( "Select A Folder", -1, 6, @ScriptDir )
$fileout = FileSaveDialog( "Save Text File", @ScriptDir, "All (*.*)|Text files (*.txt)", 18, "file list.txt")

; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile($folder & "\*.*")  

; Check if the search was successful
$time = TimerStart()
$fileout = FileOpen( $fileout, 2 )
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    FileClose($search)
    FileClose($fileout)
    Exit
EndIf

While 1
    $file = FileFindNextFile($search);SEARCH #1 LEVEL
    If @error Then ExitLoop
    If StringInStr( $file, "." ) Then
        FileWriteLine( $fileout, $file )
    Else
        FileWriteLine( $fileout, "|" & $file )
        $search2 = FileFindFirstFile($folder & "\" & $file & "\*.*")
        While 1
            $file2 = FileFindNextFile($search2);SEARCH #2 LEVEL
            If @error Then ExitLoop
            If StringInStr( $file, "." ) Then
                FileWriteLine( $fileout, "-----" & $file2 )
            Else
                FileWriteLine( $fileout, "+----" & $file2 )
                $search3 = FileFindFirstFile($folder & "\"  & $file & "\" & $file2 & "\*.*")
                While 1
                    $file3 = FileFindNextFile($search3);SEARCH #3 LEVEL
                    If @error Then ExitLoop
                    FileWriteLine( $fileout,"     +----" & $file3 )
                WEnd
            EndIf
        WEnd
    EndIf
WEnd
; Close the search handle
FileClose($fileout)
FileClose($search)
$time = TimerStop( $time )
MsgBox(0, "Done", "Time to write: " & Round($time, 3) & " milliseconds")

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites



Smoke made a UDF to get all files no matter how many subdirectories ;)

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