Delete all files except one folder

  • Thread starter Thread starter liu
  • Start date Start date
Consider using the freeware 'XXCOPY'

(http://www.xxcopy.com/xcpymain.htm) to do that job.



I created a structure similar to what you described and did a quick

batch file. It seems to do what you want:





Code:

--------------------

xxcopy /clone /yy F:\projects\project???\source\*.* F:\projectsxxcopy

xxcopy /clone /yy F:\projectsxxcopy F:\projects\

RD F:\projectsxxcopy /s /q

--------------------





Use quotes if you have embedded spaces in your path.



It simply copies all project folders to an intermediate folder and then

clones that folder back to the original, thus deleting all files and

folders except those named projects and source.



xxcopy is a great time saver for situations like yours.
 
Here's how it worked:



BEFORE:



Code:

--------------------

F:\projects>tree /f

Folder PATH listing for volume f10gig D2P1

Volume serial number is 0006EE44 E48B:68F4

F:.

¦ deleteme.txt

¦

+---Project001

¦ ¦ deleteme.txt

¦ ¦

¦ +---Source

¦ keepme.txt

¦

+---project002

¦ ¦ deleteme.txt

¦ ¦

¦ +---source

¦ keepme.txt

¦

+---Project111

¦ ¦ deleteme.txt

¦ ¦

¦ +---Source

¦ keepme.txt

¦

+---project222

¦ ¦ deleteme.txt

¦ ¦

¦ +---Source

¦ keepme.txt

¦

+---project999

¦ deleteme.txt

¦

+---source

keepme.txt

--------------------





AFTER:



Code:

--------------------

F:\projects>tree /f

Folder PATH listing for volume f10gig D2P1

Volume serial number is 0006EE44 E48B:68F4

F:.

+---Project001

¦ +---Source

¦ keepme.txt

¦

+---project002

¦ +---source

¦ keepme.txt

¦

+---Project111

¦ +---Source

¦ keepme.txt

¦

+---project222

¦ +---Source

¦ keepme.txt

¦

+---project999

+---source

keepme.txt

--------------------





Does that look like what you are trying to achieve?
 
I'm chiming in at the end of what I imagine is

an extended conversation, but:



If the object is just what the subject line says, to

delete all of a large body of files except for one

folder in that body, then make the chosen folder

hidden, and make sure hidden files are not shown.

Then any deletion of the body as a whole will

leave the one hidden folder in existence, after

which it can be un-hidden whenever that becomes

desirable.



Or am I missing the point of the discussion?
 
"Anthony Buckland" wrote in message

news:D62dnavPPtzpu4TRnZ2dnUVZ_hednZ2d@giganews.com...

> I'm chiming in at the end of what I imagine is

> an extended conversation, but:

>

> If the object is just what the subject line says, to

> delete all of a large body of files except for one

> folder in that body, then make the chosen folder

> hidden, and make sure hidden files are not shown.

> Then any deletion of the body as a whole will

> leave the one hidden folder in existence, after

> which it can be un-hidden whenever that becomes

> desirable.

>

> Or am I missing the point of the discussion?




No, you're not and I love this bit of lateral thinking!
 
> --------------------

>     xxcopy /clone /yy F:\projects\project???\source\*.* F:\projectsxxcopy

>   xxcopy /clone /yy F:\projectsxxcopy F:\projects\

>   RD F:\projectsxxcopy /s /q

> --------------------

>

> Use quotes if you have embedded spaces in your path.

>

> It simply copies all project folders to an intermediate folder and then

> clones that folder back to the original, thus deleting all files and

> folders except those named projects and source.

>

> xxcopy is a great time saver for situations like yours.




It worked. THANKS A LOT!!!
 
"surferdude2" wrote in message

news:surferdude2.4cpf8q@no.email.invalid...

>

> Consider using the freeware 'XXCOPY'

> (http://www.xxcopy.com/xcpymain.htm) to do that job.

>

> I created a structure similar to what you described and did a quick

> batch file. It seems to do what you want:

>

>

> Code:

> --------------------

> xxcopy /clone /yy F:\projects\project???\source\*.* F:\projectsxxcopy

> xxcopy /clone /yy F:\projectsxxcopy F:\projects\

> RD F:\projectsxxcopy /s /q

> --------------------

>

>

> Use quotes if you have embedded spaces in your path.

>

> It simply copies all project folders to an intermediate folder and then

> clones that folder back to the original, thus deleting all files and

> folders except those named projects and source.

>

> xxcopy is a great time saver for situations like yours.

>




I think shools should test students for criminal apptiude so they know they

aren't cut out for it and can lead more productive lives. Doubtful time in a

correctional facility will cure you and the citizens will be paying for your

keep the rest of your life. Wasting other peoples lives too, your family

included. I'd say 240grains of lead is the only thing to cure the two of

you. Don't really care if that's not what the two of you are doing.

Spreading this kind of crap makes you guilty too.



http://www.missingkids.com/



Anyone still wondering why newsgroups are going away.
 
On Fri, 18 Jun 2010 05:42:45 -0400, "T Shadow" wrote:



>"surferdude2" wrote in message

>news:surferdude2.4cpf8q@no.email.invalid...

>>

>> Consider using the freeware 'XXCOPY'

>> (http://www.xxcopy.com/xcpymain.htm) to do that job.

>>

>> I created a structure similar to what you described and did a quick

>> batch file. It seems to do what you want:

>>

>>

>> Code:

>> --------------------

>> xxcopy /clone /yy F:\projects\project???\source\*.* F:\projectsxxcopy

>> xxcopy /clone /yy F:\projectsxxcopy F:\projects\

>> RD F:\projectsxxcopy /s /q

>> --------------------

>>

>>

>> Use quotes if you have embedded spaces in your path.

>>

>> It simply copies all project folders to an intermediate folder and then

>> clones that folder back to the original, thus deleting all files and

>> folders except those named projects and source.

>>

>> xxcopy is a great time saver for situations like yours.

>>


>

>I think shools should test students for criminal apptiude so they know they

>aren't cut out for it and can lead more productive lives. Doubtful time in a

>correctional facility will cure you and the citizens will be paying for your

>keep the rest of your life. Wasting other peoples lives too, your family

>included. I'd say 240grains of lead is the only thing to cure the two of

>you. Don't really care if that's not what the two of you are doing.

>Spreading this kind of crap makes you guilty too.

>

>http://www.missingkids.com/

>

>Anyone still wondering why newsgroups are going away.

>






WindowsXP ???????????????????????????
 
liu;1222390 Wrote:

> > --------------------

> > * * xxcopy /clone /yy F:\projects\project???\source\*.*


> F:\projectsxxcopy

> > * xxcopy /clone /yy F:\projectsxxcopy F:\projects\

> > * RD F:\projectsxxcopy /s /q

> > --------------------

> >

> > Use quotes if you have embedded spaces in your path.

> >

> > It simply copies all project folders to an intermediate folder and


> then

> > clones that folder back to the original, thus deleting all files and

> > folders except those named projects and source.

> >

> > xxcopy is a great time saver for situations like yours.


>

> It worked. THANKS A LOT!!!




XXCOPY is a powerful tool - use it with caution! It is extremely

important to always include a target folder other than the root folder

when using the /clone switch, especially if including the /yy switch

which prevents any confirmation prompts. Cloning to a target root

folder will wipe all data from the target folder and replace it with the

source data. That's not what is usually desired, to say the least.



All the best,



Dude
 
On 6/18/2010 2:42 AM, T Shadow wrote:

> "surferdude2" wrote in message

> news:surferdude2.4cpf8q@no.email.invalid...

>>

>> Consider using the freeware 'XXCOPY'

>> (http://www.xxcopy.com/xcpymain.htm) to do that job.

>>

>> I created a structure similar to what you described and did a quick

>> batch file. It seems to do what you want:

>>

>>

>> Code:

>> --------------------

>> xxcopy /clone /yy F:\projects\project???\source\*.* F:\projectsxxcopy

>> xxcopy /clone /yy F:\projectsxxcopy F:\projects\

>> RD F:\projectsxxcopy /s /q

>> --------------------

>>

>>

>> Use quotes if you have embedded spaces in your path.

>>

>> It simply copies all project folders to an intermediate folder and then

>> clones that folder back to the original, thus deleting all files and

>> folders except those named projects and source.

>>

>> xxcopy is a great time saver for situations like yours.

>>


>

> I think shools should test students for criminal apptiude so they know they

> aren't cut out for it and can lead more productive lives. Doubtful time in a

> correctional facility will cure you and the citizens will be paying for your

> keep the rest of your life. Wasting other peoples lives too, your family

> included. I'd say 240grains of lead is the only thing to cure the two of

> you. Don't really care if that's not what the two of you are doing.

> Spreading this kind of crap makes you guilty too.

>

> http://www.missingkids.com/

>

> Anyone still wondering why newsgroups are going away.

>

>


Hey, Shadow, if you don't understand what these people are doing, just

keep quiet, please.
 
Back
Top