1.

Solve : Need help with housekeeping of files?

Answer»

Hi,

How can I do some housekeeping of files. Evertime I copy a new set of files to a SERVER, I backup the old files to a log folder with today's date. I just want to maintain the most recent 5 log folders.

I have attached an image with this post. It shows my directory structure. What I want to do is maintain the 5 most recent folders.

Any IDEAS??

[attachment deleted by admin]You have two different naming conventions in the high level folder. This snippet shows method as opposed to a written in granite solution. Currently the snippet sorts the folders by descending date, then KEEPS the most current five.

Code: [Select]@echo off
for /f "skip=5 tokens=* delims=" %%i in ('dir \\dnroot\data\equities\prime\ecm\backup /a:d /b /o:-d') do (
echo %%i
)

The snippet will list the folders to be deleted. When you are satisfied with the results, change echo to rd /s /q.

Quote

You have two different naming conventions in the high level folder.

Yeah, I need to modify that. EVENTUALLY, It will only have one naming convention.

But yet again, this is exactly what I wanted. works perfect.

Everytime I have posted a question, your answer has been perfect, bang on target. You are a guru of batch programming. I am sure you have acquired this knowledge due to years of experience with Batch scripting.

I would like to learn batch scripting in detail. Most of the things are quite easy, except for complicated for loops. Could you suggest me some BOOK. Also some best practices, things that should not be missed when coding a Batch program.

Maybe Admin's could start a new topic that could be helpful to all..

Thanks once again Sidewinder.. You Rock!!! Back in the day when DOS was an operating system and not some misquoted acronym, both the IBM and Microsoft DOS actually came with manuals. Really!

Nowadays, you buy a Windows operating system and Microsoft kicks you in the *censored* and wishes you good luck. Really!

This article may be what you're looking for. Be sure to check out the epilog for that wish of good luck.





Discussion

No Comment Found