Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter dir contents by file type and then dislpay

Status
Not open for further replies.

EddieVenus

Technical User
Apr 8, 2002
176
US
i am looking for a way to filter out just the file types I want to display from a given folder/web dir. This sounds easy enough, but I have not successfully come up with a way to do this. I have a drive full of folders. Each folder represents a different client, within every client folder are word .docs, excel files, Visio drawings and assorted misc files. I am looking to make it easy for the intranet users to see the folder tree, select the client folder to open, then inside that folder only see one file type, i.e only pdf files. The file type can be hard coded since i only need this for one type of file for now. I want this to be similar to either web browsing or to windows explorer, but I suppose this could be tweaked once i can get working code in place to do the other things I wanted.
 
yes that is good, but is there some way now to specify what file type it will display? This page just displays all files in said directory. That is useful, as it is the same as an fso I have been using so far. but I need to know how to make it select only certain files, like in the case of the above link he displays picture files, but he must only have picture files in this directory since the script does not specify what file type to display.
 
Get the name and store it in a string.

Use the Len function to get the string lenght.

Use the Mid function to get the last 3 digits of the string.

I'm not sure if that will be useful.

====================================
I love people. They taste just like
chicken!
 
OK I see where you are going with this, I will try it, if I can figure out all the code. I am still very new at ASP/VB coding. I will let you know if it works. If someone who is any good at this knows how to write this, it would help to see how it goes. If you know of other ways to find the extension too that might be of use too.
 
Just for anyone who wants to know, I did find something out. This does what I wanted without all the hassles. It may come in handy for others trying to do this now. It is still in the works though since I am trying to get it to display the contents of a folder on a shared drive, and IIS 5 is having issues with that. In this code, i set it back to looking in the test folder (inetpub) but the server.mappath is still pointing to a shared folder out there. If anyone knows how to make shared folders appear to the web server please let me know. Thank you.
-----------------------------
<%
dim objFSO, objF, objFC
dim f1, w, h, c, strType

Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objF = objFSO.GetFolder(&quot;c:\inetpub\dbconn\&quot;)
'Set objF = objFSO.GetFolder(Server.MapPath(&quot;/mdrive/111data/&quot;))
Set objFC = objF.Files

response.write &quot;<table border=&quot;&quot;1&quot;&quot; cellpadding=&quot;&quot;5&quot;&quot;>&quot;

For Each f1 in objFC
if instr(ucase(f1.Name), &quot;.TXT&quot;) then
response.write &quot;<tr><td>&quot; & &quot;<a href=&quot; & Server.MapPath(objF) & &quot;/&quot; & f1.name & &quot;>&quot; & f1.name & &quot;</a>&quot; & &quot;</td><td>&quot; & f1.DateCreated & _
&quot;</td><td>&quot; & f1.Size & &quot;</td><td>&quot;
response.write &quot;</tr>&quot;

end if
Next

response.write &quot;</table>&quot;

set objFC = nothing
set objF = nothing
set objFSO = nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top