1.

Solve : deleting files older than 3 months?

Answer»

hi
i want to delete files from certain folders and subfolders in a directory, which are 3 months old. The modified date of the file is to be checked . if it is older than 3 months it is to be deleted.i need to use a batch file for this. can anybody help...you can use vbscript to calculate time or you can use GNU find for win32, downloadable here . Follow the instructions, then on the command line
Code: [Select]c:\> find path -type f -mtime +90 -exec del {} \;
thanx for the reply. I wanted to know is it not possible to write a batch file for this . Actually i require a batch script which i will schedule to run once a month , to achieve the purpose. So if anyone can provide me a batch file meeting my requirement , i would be really glad. and also thanx in advance.Here is one way to do it, and it would require use of a third party utility program. It can check the filedate, and exit with an errorlevel that can indicate if the file is more or less than 90 DAYS old.
You write your batch file to trap that errorlevel and ACT on it.

The utility program is free.
You can download it here:
http://home.mnet-online.de/horst.muc/main.htm
See Isdate

You would not be using any scripting, but only batch files and the free util program.
Before we go any further, would this be of use to you?



Quote from: elroth on February 15, 2008, 07:18:28 AM

thanx for the reply. I wanted to know is it not possible to write a batch file for this . Actually i require a batch script which i will schedule to run once a month , to achieve the purpose. So if anyone can provide me a batch file meeting my requirement , i would be really glad. and also thanx in advance.
i have shown you in my post. the utility is called find and how you would use it in a command prompt. you can easily adapt to a batch script. Just that one line will do what you want. And yes , its possible. What it takes is a LITTLE bit of effort to get started.Won't that conflict with the built in Windows find? I had to rename the GNU ECHO util to gnuecho.exe to avoid a similar problem.
Quote from: Dias de verano on February 16, 2008, 12:25:52 PM
Won't that conflict with the built in Windows find? I had to rename the GNU echo util to gnuecho.exe to avoid a similar problem.

it won't. If you installed GNU find in say C:\gnutils\bin , then just simply putting this path in front of your current PATH ENVIRONMENT variable will enable the OS to run the GNU find first. nobody says you need to install into system32 Quote from: ghostdog74 on February 16, 2008, 07:46:53 PM
If you installed GNU find in say C:\gnutils\bin , then just simply putting this path in front of your current PATH environment variable will enable the OS to run the GNU find first.

Excellent tip. Thanks.


Discussion

No Comment Found