I have this code... which is great! It displays a list of all the PDF files within a folder... but this script will only show the files within the folder that the script is in... I want to show all PDF files within a folder called blueprint. Any ideas? <% set FileSysObj=CreateObject("Scripting.FileSystemObject") strFileAndPath = request.servervariables("SCRIPT_NAME") strPathOnly = Mid(strFileAndPath,1 ,InStrRev(strFileAndPath, "/")) strFullPath = server.mappath(strPathOnly) set fldr=FileSysObj.GetFolder(strFullPath) set FileList = fldr.Files For Each FileIndex in FileList 'This bit includes only PDF files if Lcase(right(FileIndex.Name, 4)) = ".pdf" then Dim issue issue = Left(FileIndex.name,Len(FileIndex.name)-4) Response.Write("<li><A HREF='" & FileIndex.name & "'>" & issue & "</A></li>") end if Next %> Code (markup):
Just a guess, as I'm no expert, but changing the following line... strPathOnly = Mid(strFileAndPath,1 ,InStrRev(strFileAndPath, "/")) Code (markup): from the "/" at the end to be the folder name or path where you want it to search for or list the PDF files.
Are there subdirectories under the parent directory? If so, you need to loop through the SubFolders collection and get any and all .PDF files too. Here is a small snippet: Dim objFolder As Scripting.Folder Dim objFile As Scripting.File Dim objSubdirs As Scripting.Folders Dim objLoopFolder As Scripting.Folder Set objFolder = m_objFSO.GetFolder(strPath) For Each objFile In objFolder.Files If UCase$(Right$(objFile.ShortPath, 4)) = ".PDF" Then 'Perform Business Rules End If Next objFile Set objSubdirs = objFolder.SubFolders For Each objLoopFolder In objSubdirs 'Recursive Call or Code as Needed Next objLoopFolder Set objSubdirs = Nothing Set objFolder = Nothing