Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 scan directory to populate database?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

sogoth
New Member

United Kingdom
73 Posts

Posted - 29 August 2001 :  10:57:49  Show Profile  Visit sogoth's Homepage
Heya

I'm trying to build up a searchable gallery of images, unfortunately I have about 400 odd photos to put into the database. To start off with all I need to do is get all the image names into the access database. Can anyone reccomend a simple way of doing this please?

is it possible to create some form of script that will go through and read the file names in a directory and place each one as a new record into a database table? if so how would I go about doing this?

thanks!

Paul -
Complete Muppet, Borderline Feeble!

Edited by - sogoth on 29 August 2001 11:22:56

Doug G
Support Moderator

USA
6493 Posts

Posted - 30 August 2001 :  00:44:16  Show Profile
You should be able to use the Filesystem Object (FSO) to do this. I don't have any code handy, but the documentation can be found at www.microsoft.com/scripting and there are examples of reading directory/file names.


======
Doug G
======
Go to Top of Page

sogoth
New Member

United Kingdom
73 Posts

Posted - 30 August 2001 :  03:53:13  Show Profile  Visit sogoth's Homepage
thanks! I'll go have a peek at that

Paul -
*bugger* said the fairy as it flew into a window
Go to Top of Page

MorningZ
Junior Member

USA
169 Posts

Posted - 31 August 2001 :  21:34:10  Show Profile  Visit MorningZ's Homepage  Send MorningZ an AOL message
here's some

i just whipped this out from another similar script i use, so this is untested, but it should work, set your connection string, put this in the folder to get the file names from, and view in browser


<%@ Language=VBScript %>
<%
Response.Expires = -1
Server.ScriptTimeout = 400

'What dir we in?
strURLPath = Left( Request.ServerVariables("PATH_INFO"), _
InstrRev( Request.ServerVariables("PATH_INFO") , "/" ) )

Set fs = CreateObject("Scripting.FileSystemObject")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open <<your connection string>>
%>
<html>
<head>
</head>
<body>
<h2>Adding to DB</h2>
<br>
<% AddFileNames( strURLPath ) %>
<br>
</body>
</html>
<%
Sub AddFileNames(folderspec)
Dim f, strFile, fc, s, sFileName
Set f = fs.GetFolder( Server.MapPath( folderspec ) )
Set fc = f.Files

For Each strFile in fc
sFileName = strFile.name
if (Lcase( Right( sFileName, 4 ) ) = ".jpg") or (Lcase( Right( sFileName, 4 ) ) = ".gif") then
Response.Write sFileName & " added...<br>"
strSQL = "INSERT INTO ImageTable ( ImageLocation ) VALUES ( '" & folderspec & sFileName & "' )"
objConn.Execute strSQL
end if
Next
End Sub
%>






Edited by - MorningZ on 31 August 2001 21:37:27
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000 Version 3.4.07