Skip to main content
Inspiring
June 8, 2006
Answered

delete all files in directory

Is there a way to delete all the files in a specified folder using cffile? e.g.

<cffile action="delete" file="#expandpath('applications/'*.*)#" />

Where *.* is the command to delete all files?
This topic is closed to new replies. Start a new post to keep the conversation going.
AbinidiCorrect answer
Inspiring
June 8, 2006
<cfdirectory name="maindir" directory="#expandpath('applications)#">
<cfloop query="maindir">
<cfset cffile_file = "#expandpath('applications')#\#name#">
<cffile action="delete" file="#cffile_file#">
</cfloop>

2 replies

csber3Author
Inspiring
June 8, 2006
The first line was missing an ' after applications but its working now. Thanks!
Translate
AbinidiCorrect answer
Inspiring
June 8, 2006
<cfdirectory name="maindir" directory="#expandpath('applications)#">
<cfloop query="maindir">
<cfset cffile_file = "#expandpath('applications')#\#name#">
<cffile action="delete" file="#cffile_file#">
</cfloop>
Translate