Jump to content
Sign in to follow this  

Making an index of files in a dir

Recommended Posts


This is my thrid script and want you all to take a look at it. Maybe you could use the code for your own purpose. If anyone has any ideas on how I can make it neater, please don't hesitate.



#Include <File.au3>
#Include <Array.au3>
#include <GUIConstants.au3>

Dim $DefualtPath
Dim $FileList
Dim $FileString
Dim $i
Dim $File
Dim $LineOne
Dim $LineTwo
Dim $LineThree
Dim $Step
Dim $MaxFiles

; Read the last selected path.
; Defualt path
$DefualtPath = FileSelectFolder("Choose a folder.", "", 1, $DefualtPath)
; Change current path to defualt path
; Record the last selected path.

$FileList = _FileListToArray($DefualtPath)
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
_ArraySort($FileList); Sort Ascending
$MaxFiles = UBound($FileList)

$File = FileOpen("sitemap.html", 1)

; Check if file opened for writing OK
If $File = -1 Then
    MsgBox(0, "Error", "Unable to open file.")

; progress bar
GUICreate("Creating file. Please wait.",220,50,-1,-1,$WS_CAPTION)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$labelProfressbar1 = GUICtrlCreateLabel ("Creating file. Please wait",  10, 30, 200)
GUISetState ()

; Line one - All the top html code
$LineOne = "<html>" & @CRLF & "<head>" & @CRLF & "<title>Site Map</title>" & @CRLF & "</head>" & @CRLF & "<body>" & @CRLF
FileWriteLine($File, $LineOne); Write Line one
$LineTwo = "<BR />" ; Line two is the break line

$i = 0
While $i < $MaxFiles
    FileWriteLine($File, "<a href='" & $FileList[$i] & "'>" & $FileList[$i] & "</a>"); Make a link to the file
    FileWriteLine($File, $LineTwo); Add a break
    $i = $i + 1
    $Step = $i*(100/$MaxFiles) ; Devide 100 by the total files counted, times by the loop count.
; Round the step to whole number for Progress bar and Label.
    GUICtrlSetData ($progressbar1,Round($Step))
    GUICtrlSetData($labelProfressbar1, Round($Step) & " percent done. Total files listed" & $MaxFiles)

$LineThree = @CRLF & "</body>" & @CRLF & "</html>"
FileWriteLine($File, $LineThree)


GUICtrlSetData($labelProfressbar1, "100 percent done!!!")


Share this post

Link to post
Share on other sites
MSLx Fanboy

Someone else made a similar program a while back. I've attached a copy of the source for you to look at to see what you think, or if its the same thing (I don't know, it might be :o ).

Nicely done though, my only wish is to figure out how to interface a compiled au3 script to apache or IIS as a webpage file...I guess ConsoleWrite would work, I just have to find time... B)


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post

Link to post
Share on other sites

MSLx Fanboy,

Thanks for the feed back. I will check out there code.

I have no idea how to interface it with apache or IIS.


Share this post

Link to post
Share on other sites




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