View Full Version : Making a database of images
Roger Sherwin
30.08.2001, 18:06
Hello all
This is probably not really a dhtml issue but I want to make an ASP site with all the images on my exixting site (approx 3750 in number)
Is there a way of reading the directories with the images in and transferring the names into a database or temporarily into a table and then cut and paste into a database - otherwise it is going to take weeks making a list and retyping them all into a database
Is there a shareware program that could do this??
Any help or suggestions would be appreciated
Roger Sherwin
URL=http://www.angelfire.com/vt/corvettes
Mail=roger@beacon77.freeserve.co.uk
There are many ways to do what you want to do, none of which requiring you to enter the data by hand. For example, here is a quick ASP that will recursively walk through a directory and build a list of files (aFiles).
<%@ LANGUAGE="JAVASCRIPT" %>
<%
var sFolder = "d:/public/http";
var oFileSystem=Server.CreateObject("Scripting.FileSystemObject");
var aFiles;
fxInit();
function fxInit(){
var aFolders=DrillFolders(oFileSystem.GetFolder(sFolde r),new Array());
aFiles=GetFiles(aFolders);
}
function GetFiles(aFolders){
var aAddFiles=new Array();
for(var i=0;i<aFolders.length;i++){
var aFSFiles = new Enumerator(aFolders[i:urhpb7n7k8].Files);
while(!aFSFiles.atEnd()){
aAddFiles[aAddFiles.length] = aFSFiles.item().path;
aFSFiles.moveNext();
}
}
return aAddFiles;
}
function DrillFolders(oFolder,aFolders){
var aSubFolders=new Enumerator(oFolder.SubFolders);
while(!aSubFolders.atEnd()){
var oFolder=aSubFolders.item();
aFolders[aFolders.length]=oFolder;
if(oFolder.SubFolders.Count>0){
DrillFolders(oFolder,aFolders);
}
aSubFolders.moveNext();
}
return aFolders;
}
%>
In the BODY of the ASP, you can add the following to print out the files (now stored in aFiles):
<PRE>
<%
for(var i=0;i<aFiles.length;i++){
Response.write(aFiles[i:urhpb7n7k8] + "\n");
}
%>
</PRE>
You can filter the file list using reqular expressions, such as:
var sFile = aFiles[i:urhpb7n7k8];
if(sFile.match(/\.jpg$/i)){
Response.write(sFile + "\n")
}
You certainly would only want to do this once or twice to make your list, and not actually do it for every user ... it's just a quick solution.
Ideally, since the above example is ASP, you could make a new database connection object, such as:
var oDB = Server.CreateObject("ADODB.Connection");
Then, use the database connection and SQL statements to update your database.
Roger Sherwin
30.08.2001, 21:07
Thanks for your script but as I didn't point out in my original posting that I am not a programmer and know nothing about ASP as yet I was looking for a complete working script or program that I could use instantly
I learn how to achieve the required results by playing around with scripts and seeing what they do and then alter them to my requirements - I have never been able to get my head around programming ( writing functions etc) I will keep hunting around for a quick fix or perhaps someone knows where I can obtain a solution that will do the job for me
Roger Sherwin
URL=http://www.angelfire.com/vt/corvettes
Mail=roger@beacon77.freeserve.co.uk
not sure if these programs do export to html/asp pages, but u might check them out...
http://cnet.com/downloads/0,10151,0-10078-106-0-1-0,00.html?tag=st.dl.10012.dir.10078
u should search for media management utilities..some might have option to export ur images list into html files and such...
anders
:: http://dzygn.com ::
anders@dhtmlcentral.com
vBulletin® v3.6.7, Copyright ©2000-2008, Jelsoft Enterprises Ltd.