<cfset root="c:\inetpub\wwwroot\yourdirectory\">
<cfdirectory name="dGetDir" directory="#root#" action="List">
<cfloop query="dGetDir">
        <cfif type NEQ "DIR">
                <cffile action="DELETE" file="#root##dGetDir.name#"
variable="content">
        </cffile>
</cfloop>

That'll delete everything but sub-directories within the specified
directory

Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net
[EMAIL PROTECTED]
(704) 569-9044 ext. 254
 
************************************************************************
*************
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of 
Garrison Enterprises Inc.
 
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you 
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]
************************************************************************
*************


-----Original Message-----
From: David Adams [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, December 03, 2002 4:22 PM
To: CF-Talk
Subject: Recursive File Delete


I am looking for a simple block of code that will loop through a
directory and delete it's files when called.  I do NOT want to delete
the directory, only its contents.
 
Pseudo code:
 
Set CurrentDirectory
For each file in directory
 Delete it
Next.
 
I am sure this is easy for some of you and I would be interested to see
who can do it the most eloquently.
 
Thanks again CF-Talk
 
Dave Adams
CFUG Ottawa



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to