[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Deleting multiple files with CFFILE

Posted on 2004-11-02
3
Medium Priority
?
1,372 Views
Last Modified: 2013-12-24
I want to delete all files on a directory as a scehduled cleanup function.

I gather CFFILE doesn't allow filename templates like so:

    <cffile action = "delete" file = "\test\badfile*.png">

Does anyone have a handy loop for doing this?

0
Comment
Question by:451ls
3 Comments
 
LVL 7

Expert Comment

by:INSDivision6
ID: 12479758
Use <cfdirectory> to get file names.  Loop over results and delete files with <CFFILE>

OR

<cfexecute> to delete files like "c:\test\del *.png"
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 12479815
INSDivision6 good answer.
Though I usually use CFdirectory as it is not related with any platform.
Though, nothing wrong with either of them.
Regards,
---Pinal
0
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 500 total points
ID: 12479961
<cfset variables.directory = "c:\temp\" />

<cfdirectory
      directory="#variables.directory#"
      action="list"
      name="qDirectory" />

<cfloop query="qDirectory">
      <cftry>
            <cffile
                  action="delete"
                  file="#variables.directory##qDirectory.name#" />
            <cfcatch>
                  <p>Could not delete file: #variables.directory##qDirectory.name#</p>
            </cfcatch>
      </cftry>
</cfloop>
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question