Cfdirectory

Discussion in 'Programming' started by youjie, Aug 30, 2007.

  1. #1
    Hi,

    I need to sort the files by filename using cfdirectory. The naming convention is FILEA_<YYYYMMDD> where YYYY stands for year, MM stands for month and DD stands for day. The latest file must be at the top of the list.

    For example:

    I have the file FILEA_20080901 and FILEA_20080902.
    It should display:
    FILEA_20080902
    FILEA_20080901


    However,
    it display:
    FILEA_20080901
    FILEA_20080902


    <cfdirectory sort="name" action="LIST"
    directory="/usr/local/apache/htdocs/files/"
    filter = "#form.filter#"
    name="mydir">


    Hope someone can help me on this.
    Thanks in advance!!
     
    youjie, Aug 30, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If it were a db query I would suggest using string functions to extract the <YYYYMMDD> portion as a separate column and ORDER BY that value. But afaik QoQ does not support string functions. So I think you'll need to do it yourself by looping through the query.

    - create an array
    - loop through the query. extract each <YYYYMMDD> value and append it to the array
    - use queryAddColumn to add the values to the query as a new column
    - use a QoQ and ORDER BY the new column
     
    cfStarlight, Aug 30, 2007 IP
  3. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Is it possible to have done a query of queries and put your order by condition to dateLastModified DESC ?
     
    datropics, Sep 1, 2007 IP
  4. om6ga

    om6ga Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi all,

    I am not sure what is the given error below. i am running on coldfusion 8 with IIS 5.1. could someone help me figure out pls? thank you.

    [​IMG]

    coldfusion.runtime.TemplateNotFoundException: File not found: /mainLogin.cfm
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:89)
    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
    at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at coldfusion.CfmServlet.service(CfmServlet.java:175)
    at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
    at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
    at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
    at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
    at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
    at jrun.servlet.FilterChain.service(FilterChain.java:101)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
    at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
    at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
     
    om6ga, Sep 5, 2007 IP
  5. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #5
    File not found: /mainLogin.cfm
     
    datropics, Sep 5, 2007 IP
  6. om6ga

    om6ga Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    mainLogin.cfm is there. its under default webserver. all the files are there.

    i am running sql 2005. also setup system DSN under ODBC which is mapped under CF admin. but there is no other DSN except the DSN i configured. any idea? thanks for reply
     
    om6ga, Sep 5, 2007 IP
  7. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #7
    1) Note your default webserver path
    2) <cfoutput>#getDirectoryFromPath(GetTemplatePath())#</cfoutput>
    3) Compare the two of
    4) adjust accordingly...
     
    datropics, Sep 5, 2007 IP
  8. om6ga

    om6ga Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have tried the steps but no go. since i am pretty new to cf, i m not sure how to run cfoutput tag. but i save as a file and run it. show page cannot be displayed. :< my default webserver path is E:\Inetpub\wwwroot

    anyway, this is the history.. this whole application is currently running fine under win2000 server, IIS 5.1, allaire CF ver4.5 and sql 2000.

    now what i am trying to migrate into another machine with win XP Pro, IIS 5.1, CF8 and sql 2005.

    I looked at the allaire admin console and set every possible as in CF8 admin console. i did all mapping variables, ODBC. may be is there anything i missed out? could someone please advise?
     
    om6ga, Sep 10, 2007 IP
  9. twalters84

    twalters84 Peon

    Messages:
    514
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Greetings,

    If you are just looking for the names of files in a directory, there is something you can do to speed up the command.

    LISTINFO="name"

    It is undocumented in CF7 but it still works.

    I had over 200,000 photos in a directory so it really helped me anyways.

    Sincerely,
    Travis Walters
     
    twalters84, Sep 10, 2007 IP
  10. om6ga

    om6ga Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you Travis. I m not just looking for some names of the files. i m trying to make the whole application works with CF8 and SQL2005 on winXP. may be i m here in the wrong thread. i m quite a newbie here. anyway thanks everyone.
     
    om6ga, Sep 11, 2007 IP