Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Getting a file list

New Here ,
Apr 23, 2008 Apr 23, 2008
I am trying to list files in a directory. It is a sub directory of where the script will run. I have the attached code, but it list in the current directory, I need it to look in the 2007_photos directory.
TOPICS
Getting started
573
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 23, 2008 Apr 23, 2008
If you want to list files in a subdirectory of the current template path, you will have to specify the subdirectory:

<cfdirectory action="list"
directory="#getDirectoryFromPath(getTemplatePath())#/mySubdirectory"
name="currentDir">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2008 Apr 29, 2008
worked great. now, say I want just the first file in the list? So I can display it as the main image?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008
if you use <cfoutput>#queryname.columnname#</cfoutput> it will reference
the FIRST ROW of the query only. or explicitly request the first row
with #queryname.columnname[1]#. for a different row, substitute [1] with
appropriate row number.

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2008 Apr 29, 2008
I am very new to ColFusion, but is this for a database query? I am just trying to get a file name from a directory, or the file list loop created at the begining of this thread.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008
<cfdirectory> returns a query object... read the docs.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2008 Apr 29, 2008
in your particular case you would use #currentDir.name[1]# to get the
first file returned by your <cfdirectory> query.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2008 Apr 30, 2008
I was kind of thinking that. Thanks a bunch!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2008 May 13, 2008
LATEST
Thanks, it worked for me!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources