Reply to topic
Get CFDIR... file list & insert to table
palyne


Joined: 23 Oct 2006
Posts: 13
Reply with quote
Hi, I'm sorry to ask such a simple question but apparently sleep deprivation has finally gotten to me, and websearches don't turn up the answer to this.

I have a bunch of files (~10,000) that are royalty-free with-permission images. I finally got them all onto my server's hard drive. Now, I need to basically use cfdirectory to go through the list of the files and insert each filename into a table.

Cfloop does this easily of course. But that's a lot to loop.

Now if this was in another table I could do a subquery like
[maxrows=100](insert into table1 filename where (select filename from table2 where recordid > [variable with counter like 100, 200, etc.]))

I do see that cfdirectory "makes the filename list available as a query object", conveniently. But I don't understand how to use the cfdirectory IN the subquery, mostly because even if I said (select filename from {cfdirectory}NAME), I don't know how to spec a LIMIT, with the subquery being the tag, such as the "where record > {number}".

And my server already seems to reboot nearly every half hour (if that) as a given, so I have no wish to pull 10,000 records into a query-with-subquery-with-write function and probably take it down again. Wink

Does anybody have ideas? A code example (if you do) would be awesome. Thanks so much.

Palyne
bobclingan
Forum Regular

Joined: 16 Sep 2004
Posts: 271
Location: Abingdon, MD
Reply with quote
Check out this article on how to return directory info using java instead of cfdirectory... it may be a better route for you to take given the size of your dataset:

http://www.coldfusionmuse.com/index.cfm/2006/10/26/Java.directory.list
palyne


Joined: 23 Oct 2006
Posts: 13
Reply with quote
Thanks Bob. You knew that off the top of your head?? I'm impressed.

I could stick this script in a page, as it refs:

Code:
<Cfsetting requesttimeout="200">
<cfscript>

currentDirectory = expandpath("../folder_With_15000_Images_In_It/");

function dirList(path) {
   return createObject("java","java.io.File").init(Trim(path)).list();
}

ftime = gettickcount();
   mylist = dirList(currentDirectory);
ftime = gettickcount() - ftime;

nfTime = gettickcount();
   nfList = createObject("java","java.io.File").init(Trim(currentDirectory)).list();
nfTime = getTickcount() - nfTime;
</cfscript>

But I don't know what to DO with whatever it gets me. I've never called data from anything but cfquery before. I don't know how the {whatever-it ends-up-with that holds the data} is to be called and placed into the sql table. I'll paypal you handholding tips if you like, but can you give me a clue, if I use the script above (replacing the directory structure), assuming it works for me, what then?


[/code]
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 547
Location: Harrisburg, PA
Reply with quote
Someone had requested this last week, and I posted my code.

This Post:
http://forums.hostmysite.com/viewtopic.php?t=3871&#12389

Will show you how to go through the array that is returned
bobclingan
Forum Regular

Joined: 16 Sep 2004
Posts: 271
Location: Abingdon, MD
Reply with quote
Cool- I totally forgot about that thread....

On another note- remember you can use <cftrace> and <cfdump> to examine variables to see what's in them- especially handy for variables that contain structures or other complex data types.
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 547
Location: Harrisburg, PA
Reply with quote
bobclingan wrote:
<cfdump> to examine variables to see what's in them- especially handy for variables that contain structures or other complex data types.


Absolutely. CFDump is your best friend Very Happy
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 766
Location: Newark, De
Reply with quote
Jason101 wrote:
bobclingan wrote:
<cfdump> to examine variables to see what's in them- especially handy for variables that contain structures or other complex data types.


Absolutely. CFDump is your best friend Very Happy


Until they make CFBlink, sure. Razz
CFBlink?
comprug
Forum Regular

Joined: 15 Feb 2006
Posts: 340
Reply with quote
CFBlink? What? Somehow I'm not getting something here...
Re: CFBlink?
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 766
Location: Newark, De
Reply with quote
comprug wrote:
CFBlink? What? Somehow I'm not getting something here...


I've been ranting for years that the <BLINK> tag was the worst tag EVER made...so a CFBLINK tag would be the worst CF tag ever. Wink
Get CFDIR... file list & insert to table
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic