![]()
[<<]Message[>>] [<<]Author[>>] [<<]Subject[>>] [<<]Thread[>>]
Number : 4539 Date : 2003-05-06 Author : Garry Deane Subject : Re: Deleting folders based on folder date Size(KB) : 2
--- In xxcopy@yahoogroups.com, "daverunda" wrote: > I have a batch file that uses XXCOPY to create a folder > named %DATE% on my D: drive and copy the contents of my > C:\DATA folder into the D:\%DATE% folder. This system > works great except that after a while I need to purge > some of these old backup folders. I asked Kan if I can > use XXCOPY to delete old folders on my D: drive based > on the folder creation date. His reply is as follows: > It seems that you are using W2k or XP if you are using the %date% system variable or did you mean the $date$ macro? If you are using W2k/XP there are a number of batch methods you could use however let's stick to what Xxcopy can do. Because %date% will produce a date format according to your particular locale settings, I'll assume you have a directory created 10 days ago which looks like D:\2003-04-26\. You'll need to adjust the following to suit whatever date format you are using. Xxcopy could create that directory using a command like: xxcopy c:\data\ d:\/$yyyy-mm-dd$\ /bu To remove a directory which was created 10 days ago, you can use the /TM switch to offset the date used in the macro to 10 days ago. xxcopy d:\/$yyyy-mm-dd$\ /rmdir/rsy/tm-10 Of course this will only delete the single directory which matches the date 10 days ago (not anything older) but on the assumption that you would be running this in a daily batch, that's OK. If you are running this only occasionally you might do something like delete all directories created during the month (approximately) 2 months ago. If run today, the following would delete all directories created in March. xxcopy d:\/$yyyy-mm$*\ /rmdir/rsy/tm-61 Another approach you might consider (if you're game) is to use Xxcopy to list the directories created AFTER the date of the directories you want to keep. Then use Xxcopy to remove the directories EXCLUDING those in the list you have just created. xxcopy d:\ /ltree/da#10/fc/foc:\save.lst xxcopy d:\ /rmdir/rsy/exc:\save.lst This is a pretty risky approach however because if something goes awry, you might lose all your backup data. I'd test VERY thoroughly before attempting this. There's probably a number of other possibilities along these lines but I'll leave that for you to play with. If you want a batch approach, let us know which OS and date format you are using. Depending on these, it may be quite simple to do in batch using the output from a /LTREE/DB#nn/FC command. Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.