Deleting contents within a folder

View: New views
8 Messages — Rating Filter:   Alert me  

Deleting contents within a folder

by Damo Drumm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi
Im trying to delete all the contents within a folder using coldfusion, but its deleting the actual folder each time

The contents of the folder contains be PDF's

has anyone any tips on deleting the contents and not the actual folder

Thanks

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328126
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Deleting contents within a folder

by Barney Boisvert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


If you don't mind synchronizing, you can just delete the directory (as
you are now) and then recreate an empty one after you're done.
Otherwise you'll need to use CFDIRECTORY to get a list of the
contained files and delete them individually with CFFILE.

cheers,
barneyb

On Monday, November 9, 2009, Damo Drumm <damien.drumm@...> wrote:

>
> Hi
> Im trying to delete all the contents within a folder using coldfusion, but its deleting the actual folder each time
>
> The contents of the folder contains be PDF's
>
> has anyone any tips on deleting the contents and not the actual folder
>
> Thanks
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328127
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

RE: Deleting contents within a folder

by LRS Scout :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Get a list of the files with cfdirectory action="list" then loop over the
files.

Delete the files with cffile action="delete"

-----Original Message-----
From: Damo Drumm [mailto:damien.drumm@...]
Sent: Monday, November 09, 2009 11:07 AM
To: cf-talk
Subject: Deleting contents within a folder


Hi
Im trying to delete all the contents within a folder using coldfusion, but
its deleting the actual folder each time

The contents of the folder contains be PDF's

has anyone any tips on deleting the contents and not the actual folder

Thanks



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328128
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Deleting contents within a folder

by Charles Sheehan-Miles-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


cfdirectory action=list

loop through the list

cffile delete based on list contents

On Mon, Nov 9, 2009 at 11:07 AM, Damo Drumm <damien.drumm@...>wrote:

>
> Hi
> Im trying to delete all the contents within a folder using coldfusion, but
> its deleting the actual folder each time
>
> The contents of the folder contains be PDF's
>
> has anyone any tips on deleting the contents and not the actual folder
>
> Thanks
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328129
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Deleting contents within a folder

by JediHomer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


You could use <CFDirectory> to get the listings of the directory, then
loop over that calling FileDelete() on the results...

2009/11/9 Damo Drumm <damien.drumm@...>:

>
> Hi
> Im trying to delete all the contents within a folder using coldfusion, but its deleting the actual folder each time
>
> The contents of the folder contains be PDF's
>
> has anyone any tips on deleting the contents and not the actual folder
>
> Thanks
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328130
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

RE: Deleting contents within a folder

by Robert Harrison-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Use cfdirectory to list the content of the directory. Then loop through the
contents and delete the files you don't want.

                <cfdirectory action="list" directory = "mydirectorypath\"
name="dirlist">

                <cfloop query="dirlist">
                        YOU COULD INSERT A TEST HERE TO SEE IF YOU NEED THE
FILE (E.G., It's referenced in a DB somewhere)
                        <cffile action="delete"
file="mydirectorypath\#dirlist.name#">
                </cfloop>




Robert B. Harrison
Director of Interactive Services
Austin & Williams
125 Kennedy Drive, Suite 100
Hauppauge NY 11788
P : 631.231.6600 Ext. 119
F : 631.434.7022
http://www.austin-williams.com 

Great advertising can't be either/or.  It must be &.

Plug in to our blog: A&W Unplugged
http://www.austin-williams.com/unplugged



-----Original Message-----
From: Damo Drumm [mailto:damien.drumm@...]
Sent: Monday, November 09, 2009 11:07 AM
To: cf-talk
Subject: Deleting contents within a folder


Hi
Im trying to delete all the contents within a folder using coldfusion, but
its deleting the actual folder each time

The contents of the folder contains be PDF's

has anyone any tips on deleting the contents and not the actual folder

Thanks



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328131
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Deleting contents within a folder

by Eric Cobb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I agree with Barney just deleting the directory and recreating it.
Having to get a list of everything in the directory and then loop
through that list and delete each item one-by-one seems "dirty" to me.

That being said, if you do want to go the list/loop/delete route, I
would suggest using CF's java capabilities to do it. cfdirectory/cffile
can kill a CF server if there are a lot of files or the files are large.

I once tried the cfdirectory/cffile approach on a directory that
contained a large amount of images (about 2 gigs worth) and it croaked.
  I changed it to use Java and it was able to do it.

This should help:
http://www.cfgears.com/index.cfm/2009/5/19/Tapping-in-to-ColdFusions-underlying-Java-capabilities 



Thanks,

Eric Cobb
http://www.cfgears.com


Barney Boisvert wrote:

> If you don't mind synchronizing, you can just delete the directory (as
> you are now) and then recreate an empty one after you're done.
> Otherwise you'll need to use CFDIRECTORY to get a list of the
> contained files and delete them individually with CFFILE.
>
> cheers,
> barneyb
>
> On Monday, November 9, 2009, Damo Drumm <damien.drumm@...> wrote:
>> Hi
>> Im trying to delete all the contents within a folder using coldfusion, but its deleting the actual folder each time
>>
>> The contents of the folder contains be PDF's
>>
>> has anyone any tips on deleting the contents and not the actual folder
>>
>> Thanks
>>
>>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328133
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Deleting contents within a folder

by Kevin Pepperman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


cflib has a function for this.

http://cflib.org/udf/deleteDirectory


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328161
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4