Where I work, we have mutiple products which create installation packages that are kept in the same directory that I will call the mainBuildDir. An installation package is a directory whose name is the product name followed by the date. Ex: ProdA_2007-06-22 The contents are multiple files and folders, perhaps nested. Some builds are run daily, every other day, once a week and so on. I have been asked to write a script to purge the mainBuildDir on a weekly basis. For each product, we are to keep no more than 7 install packages and none is to be kept longer than 9 days. We use WIN2000 but are planning on going to XP. A lot of the scripting here is DOS batch files - which I am totally new to. My background is UNIX and I have been wanting to learn Perl, so I chose that to use - using Perl is NOT a requirement. I have gotten to the main build directory, parsed that to get how many install packages there are and their names. I am stuck on parsing the main build directory into product types, that is, all ProdA's , ProdB's and so on - which I could use some direction on. Where I am really stuck is deleting a non-empty directory. I've tried "system ("DEL /Q $dir[0]"); system ("RD /Q $dir[0]");" with no success and have checked out section 9.8, Removing a Directory and Its Contents on P362 of the Perl Cookbook which uses the Find::File finddepth function and Find::Path rmtree - neither of which I understand fully. Any help or guidence will be very much appreciated. Thanks, Jim malgieri@infimed.com jammalg@rochester.rr.com

File::Path and the rmtree function sounds like the way to go if you stick with perl. There isn't much o understand, load the module into your scrip:

use File::Path;

and feed the rmtree() function the name of a directory you wat to wipe out.


You can probably feed it a list of directories too.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.