Reply
ASP FileSystemObject - Sorting & counting
Old 01-21-2009, 06:20 PM ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 440
Location: world traveller based in UK
Trades: 0
I want to quickly get a list of subfolders in a folder & also then the files in each folder.

I can get my list easy enough using a very basic script

Code:
<% 
    folder = "C:\" 
 
    set fso = CreateObject("Scripting.fileSystemObject") 
    set fold = fso.getFolder(folder) 
    for each file in fold.files 
        response.write file.name & "<br>" 
    next 
    set fold = nothing: set fso = nothing 
%>
How do I sort my files ???

Is there any easy way or do I need to put the results into a recordset. I have found some examples but some look really code intensive for something that should be I feel relatively simple.

Oh p.s if I want to count the files in the subfolder is there an easy way of doing that ???
__________________
Tonya

:: my personal site :: Marine Biology Site
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
 
When You Register, These Ads Go Away!
Old 01-21-2009, 06:33 PM Re: ASP FileSystemObject - Sorting & counting
chrishirst's Avatar
Super Moderator

Posts: 22,225
Location: Blackpool. UK
Trades: 0
Sorting files
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=118

counting the files
Code:
dim files, count
set files = fold.files
count = files.count
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2009, 06:44 PM Re: ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 440
Location: world traveller based in UK
Trades: 0
Is there an easy way to apply that to the content of each subfolder ???

Code:
Dim iCurrentCell
folderspec = Server.MapPath("/graphics/.")
strPath=Server.MapPath ("/graphics/gallery/.") 
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
Set galleryFolder = myFSO.GetFolder(strPath)
Set folcoll = galleryFolder.SubFolders


Response.Write "The folders in the <b>" & galleryFolder.Name & "</b> Folder are: <br> <br>"%>
</p>

<%
For Each subfol in folcoll
Response.Write  "<a href='photos.asp?f=" & subfol.name & "'>" 
Response.write  subfol.Name & "</a><br/>"
Response.write ""
'iCurrentCell = iCurrentCell + 1
'If iCurrentCell > 2 then 
'Response.Write(" ")
'iCurrentCell=1
'End if
Next 

set myFSO = nothing
__________________
Tonya

:: my personal site :: Marine Biology Site
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Old 01-21-2009, 06:44 PM Re: ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 440
Location: world traveller based in UK
Trades: 0
My workaround was to include a new FSO object that looked into & counted the content of each subfolder but that seems laborious for simply counting ?
__________________
Tonya

:: my personal site :: Marine Biology Site
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Reply     « Reply to ASP FileSystemObject - Sorting & counting
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11155 seconds with 13 queries