Can the contents of a folder on the server be counted.
For example could you get a count of how many text files are in a folder called mydocuments. If so, how about counting something different than text files.
AJ
I would lose my head if it wasn't attached.
You could use the FileSystemObject to get a reference to the folder your trying to look at, then loop through all the files in that folder checking the extension against your extension(s). If they one your checking matches than increment a counter. When you are finished with the loop you will have your count of filenames with extension ".whatever".
So basically:
'Create a FileSystemObject
Set fso = Server.CreateObject("Scripting.FileSystemObject"
'Create a reference to the folder in pathname
Set folders = fso.getFolder(Server.Mappath(pathname))
'Get the files collection from the folder
Set files = folders.files
'Define the extensions we planon looking for
Dim extensions, count
extensions = "htm html"
Dim file, types, fn 'Loop through the files collection looking at each file
For each file in files 'Pull out the extension for the file
fn = right(file.name,len(file.name) - InStr(file.name,".") 'Check if this extension is in the list
If InStr(extensions,fn) > 0 Then 'Increment the count
count = count + 1
End If
Next
This will count all of the extensions that exist in your extensions list as a group, so your total in this case would be all the files with .html or .htm ionstead of individual totals, I'll leave that part up to you
Hope this helps,
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.