Sign in to follow this  
Followers 0
Jeff

Making an index of files in a dir

4 posts in this topic

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.

Thanks,

Jeff

#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.
$DefualtPath = RegRead("HKEY_CURRENT_USER\SOFTWARE\DOCTALK\SITEMAP", "lastdir")
; Defualt path
$DefualtPath = FileSelectFolder("Choose a folder.", "", 1, $DefualtPath)
; Change current path to defualt path
FileChangeDir($DefualtPath)
; Record the last selected path.
RegWrite("HKEY_CURRENT_USER\SOFTWARE\DOCTALK\SITEMAP", "lastdir", "REG_SZ", $DefualtPath)


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

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

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

; 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)
WEnd

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

FileClose($File)

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

Exit

Share this post


Link to post
Share on other sites



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)

Index_Generator.zip


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.

Jeff

Share this post


Link to post
Share on other sites

*GASP!!!*

DirList!!!!!!!!!!!!!!

*GASP!!!*

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