Jump to content

Delete ALL folders except...


erebus
 Share

Recommended Posts

Hello all,

I want to complete a script but it seems like I have stuck here...

What I want to do, is to store some subfolder names to a variable (or an array) in an .INI file and to DirRemove ALL the contects of the parent folder, except the declared ones.

For example if we have:

$keep[1] = "keep.folder.1"

$keep[2] = "keep.folder.2"

$keep[3] = "keep.folder.3"

And the folder tree is like:

C:\Do.the.job.here\keep.folder.1\

C:\Do.the.job.here\keep.folder.2\

C:\Do.the.job.here\keep.folder.3\

C:\Do.the.job.here\keep.folder.4\

C:\Do.the.job.here\other.folder.1\

C:\Do.the.job.here\other.folder.2\

C:\Do.the.job.here\other.folder.3\

...I want only "keep.folder.4" and "other.folder.*" to be deleted.

Any ideas of how to accomplish this are more than welcome.

Edited by erebus
Link to comment
Share on other sites

You could have it check the path, or name, of the file by using something like _PathSplit, then using an If-Then statement, have it check for those files, and if they are those files, delete them.

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Yes, can you help me a bit more?

Give a code example if possible.

Edit: The problem here is how to check within a For/Next loop for my array. Maybe it is going to work for a one-dimensional array. What about a two-dimensional one?

Edited by erebus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...