MasterRacker
New member
I have a script that scans for files whose FQN is over a specified length. It works fine except that I want some kind of progress indicator and I can't get the display to update. Everything I've found suggests all you need to do is set a timer that calls an update routine. In my ast the update does not fire when I call before starting the scan or when the timer fires, only at the end of the process. What am I missing here?
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
Code:
<!--
'===============================================================================
' NAME: ListLongFilenames.hta
' AUTHOR: Ano Nymous
' DATE: 02/25/2011
' DESCRIPTION: Find file with longest full name plus count files over specified limit.
' Logs filenames over limit to a text file.
'===============================================================================
-->
<HEAD>
<title>List Files</title>
<HTA:APPLICATION
APPLICATIONNAME="List Files Over Limit"
SCROLL="no"
SINGLEINSTANCE="yes"
>
</HEAD>
<!-- ************************************************************************************** -->
<SCRIPT LANGUAGE="VBScript">
dim FSO, outFQN, filecnt, longcnt, outFile, file, maxlen, slen
Sub CloseScript
Self.Close()
End Sub
Sub Window_OnLoad
window.resizeTo 800,300
iTimer = window.setInterval("UpdateStatus", 500)
End Sub
Sub UpdateStatus
fileCount.InnerHTML = CStr(filecnt)
longCount.InnerHTML = CStr(longcnt)
maxLength.InnerHTML = CStr(maxlen)
End Sub
Sub RunScript
set FSO = CreateObject("Scripting.FileSystemObject")
outFQN = outfiletxt.Value
'----- If the output file does not exist, create it
if not FSO.FileExists(outFQN) then
FSO.CreateTextFile(outFQN)
end if
'----- Open file for append
const ForReading = 1
const ForWriting = 2
const ForAppending = 8
set outFile = FSO.OpenTextFile (outFQN, ForWriting, true)
'========================= Logfile Initialization - End
longcnt = 0
filecnt = 0
maxlen = 0
UpdateStatus
ListFiles FSO.GetFolder(startfolder.Value)
outFile.WriteLine ("Longest name found: " & CStr(maxlen))
UpdateStatus
'----- Cleanup
set FSO = nothing
outFile.Close
End Sub
Sub ListFiles(folder)
For Each file In folder.Files
filecnt = filecnt + 1
slen = len(file.Path)
if slen > maxlen then
maxlen = slen
end if
if slen > CInt(cutofflen.value) then
longcnt = longcnt + 1
outFile.WriteLine ("""" & file.Path & """," & CStr(slen))
outFile.WriteLine ("")
end if
Next
For Each subfolder In folder.SubFolders
ListFiles(subfolder)
Next
End Sub
</SCRIPT>
<!-- ************************************************************************************** -->
<BODY>
Starting Folder: <input type="text" name="startfolder" style="width:300px" /><BR />
Output File: <input type="text" name="outfiletxt" style="width:300px" value="C:\test\filelist.txt" /><BR />
Cutoff: <input type="text" name="cutofflen" style="width:50px" value="240" /><BR />
<BR />
<input id=runbutton class="button" type="button" value="Run" name="run_button" onClick="RunScript">
<input id=runbutton class="button" type="button" value="Close" name="close_button" onClick="CloseScript">
<BR /><BR />
Files Scanned: <span ID="fileCount"></span><BR />
Files Over Limit: <span ID="longCount"></span> Max Length Found: <span ID="maxLength"></span>
</BODY>
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]