Skip to main content
Inspiring
April 3, 2008
Question

Use database row field to batch rename 500 .jpg's ?

  • April 3, 2008
  • 3 replies
  • 485 views
I have a database in which contains 500 hundred rows.
Each row has a field called product_code eg. PF133
Each row has another field called filename eg. 12a5f.jpg , which matches the filename of an actual jpg file on the hard disk (500 of them)

At present a user can pull up any row in the database and click the filename to see the jpg on-screen

What I need to do is batch rename all the .jpg files on the hard disk so they are of the format produce_code.jpg

What's the best way to do this ?
    This topic has been closed for replies.

    3 replies

    Inspiring
    April 3, 2008
    jdeline wrote:
    > The concept code below should get you started.
    >
    >
    >
    > <CFQUERY NAME="myImages" ... >
    > SELECT product_code, filename FROM myTable
    > </CFQUERY>
    >
    > <CFLOOP QUERY="myImages">
    > <CFFILE ACTION="rename" SOURCE="%absolutePathname%/#filename#"
    > DESTINATION="%absolutePathname%/#productCode#.jpg >
    > </CFLOOP>
    >

    Don't forget to update the table with the new filename as well.

    Inspiring
    April 3, 2008
    quote:

    Originally posted by: Newsgroup User
    jdeline wrote:
    > The concept code below should get you started.
    >
    >
    >
    > <CFQUERY NAME="myImages" ... >
    > SELECT product_code, filename FROM myTable
    > </CFQUERY>
    >
    > <CFLOOP QUERY="myImages">
    > <CFFILE ACTION="rename" SOURCE="%absolutePathname%/#filename#"
    > DESTINATION="%absolutePathname%/#productCode#.jpg >
    > </CFLOOP>
    >

    Don't forget to update the table with the new filename as well.




    will do
    Inspiring
    April 3, 2008
    Thank you so much jdeline!
    April 3, 2008
    The concept code below should get you started.