Avatar of judsonmusic
judsonmusic
Flag for United States of America asked on

CFDIRECTORY TO GET FOLDER LIST?

Can you use cfdirectory to get a list of folder in a location?????

If not what alternative do I have to do that?
ColdFusion Language

Avatar of undefined
Last Comment
SidFishes

8/22/2022 - Mon
SidFishes

just add the TYPE="dir" attribute to your cfdirectory tag

judsonmusic

ASKER
SID,

How to I also tell it to only look for .jpg files???
SidFishes

use the Filter="*.jpg" attribute


obviously you can't combine type="dir" and filter="*.jpg"  

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
judsonmusic

ASKER
SID the type attribute was not allowed.

this is my code:

<cfdirectory name="getAlbums" action="list" type="dir" directory="\\Devserver\e\Websites\judsonmusic\images\">
judsonmusic

ASKER
Any ideas?
ASKER CERTIFIED SOLUTION
SidFishes

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SidFishes

you should remove <cfdump var="#dirsArray#">
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
judsonmusic

ASKER
in that code, where are you showing the file path to get the folder from?

Can you plug my code elements into it so I can see it work?
SidFishes

the exmaple just lists all the dir in c:\

<cfdirectory directory="C:\" name="dirQuery" action="LIST">
                                      ^

just substitute your cfdirectory

 <cfdirectory name="getAlbums" action="list" type="dir" directory="\\Devserver\e\Websites\judsonmusic\images\">
judsonmusic

ASKER
oh, so you are using the type in the code to build an array of the folder where these are listed?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SidFishes

yes... in cf7 "type" was part of the result struct with a value of "dir" or "file" so you need to loop thru the returned struct and pick out the values with dir as type

judsonmusic

ASKER
So now in coldfusion 8, you can do it so much simpler huh??
SidFishes

much simpler yes...
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SidFishes

need any more help