Wildcard cfquery & delete files?
Posted on 2009-07-03
I have a situation where I have a very large directory of filenames, that are regulary imported via FTP automatically.
Since they are not imported via coldfusion, there isnt a database associated with which files belong to which records. The filenames themselves do contain names that allow me to associate them with their corresponding records, so I can query & retrieved the files as needed, but I am having trouble figuring out how to delete the files when the records become outdated.
I need to be able to do a an entire directory search of what is in the FTP folder against the records that are actually active in my database.
Is there a way I can wildcard delete files? For instance if my records are labeled from 1000-2000. The associated records for record 1000 are labeled 1000-1, 1000-2, 1000-3, etc.
What I need to do is check the files in the directory against record numbers and delete any files in the directory that do not have a corresponding record in the database. So if I run the code every week, it can wildcard delete any file that contains a record number in the filename that no longer exists in the live database.