Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Files

Status
Not open for further replies.

MrSki

Programmer
Dec 13, 2000
66
US
I am trying to delete a directory, but I get the error where the directory is not empty. So I first issue the command...

<CFFILE ACTION=&quot;DELETE&quot; FILE=&quot;\\webdev\e-share\webdev\BackendDev\OLC\image\#URL.Org#\*.*&quot;>

but it does not seem to like the wildcards.

How can I delete a directory AND its files or at least a whole series of files?
Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
Never actually had to delete a directory, but have deleted a file before. If you use cfdirectory to get a list of all of the files that are in the directory that you want, and then loop over that query deleting the files that are returned from the query, once that is finished, you should be able to delete the directory with a cfdirectory delete

Like this:

<CFDIRECTORY ACTION=&quot;LIST&quot; DIRECTORY=&quot;E:\projects\generic\news&quot; NAME=&quot;dirlist&quot;>

<cfoutput query=&quot;dirlist&quot;>
<!---Check to see if file exists here --->
<CFFILE ACTION=&quot;Delete&quot; FILE=&quot;#name#&quot;>
</CFOUTPUT>

<CFDIRECTORY ACTION=&quot;Delete&quot; DIRECTORY=&quot;mydirectory&quot;>

Hope this helps !
 
That makes a lot of sense. I did not even think of looping through the list. I will give that a try.

Thanks! Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top