Find file in a directory based on ID# in filename with ColdFusion 9

611 views Asked by At

I've got a page that displays a specific video for donors who receive an email from our foundation. The email uses variable data to create a URL with the donor's ID# from our database like this: http://www.mysite.com/index.cfm?type=thankyou&id=123456&fn=John. My page is designed to serve up the personalized video based on the Donor ID#.

I have a folder with the videos. The video naming convention includes the donor ID# thankyou/thankyou_123456_J_Smith.mp4.

How do I search the directory and find the file I'm looking for based solely on the Donor ID#?

Do I need to run a cfdirectory, create a list, run a find and then use that info somehow? OR can cfdirectory look for a partial name and match that to serve up the correct file?

1

There are 1 answers

3
Paul On BEST ANSWER
<cfdirectory action="list" directory="c:\" name="data" filter="#donorId#" />

This should do it. List the files in the directory with a filter ensureing the filename includes the donor ID.