Computing.Net > Forums > Programming > HELP Del Files Older Than 15 Days?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

HELP Del Files Older Than 15 Days?

Reply to Message Icon

Name: Jheds
Date: December 20, 2006 at 04:36:28 Pacific
OS: WIN XP
CPU/Ram: 512
Product: DELL Optiplex
Comment:

Hi People,

Please help me with the DOS code to delete files older than 15 days. i will schedule the batch file then.
We are doing this to delete older backup files and preserve latest files only to save on disk space.

Please Help soon

Regards,

Jheds



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: December 20, 2006 at 05:03:21 Pacific
Reply:

We've been on the subject of 'date math' many times, with no joy.

A more fruitful approach would be to keep the most recent X number of files.



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: Jheds
Date: December 20, 2006 at 06:16:39 Pacific
Reply:

Hi there Mechanix

How will we keep the most recent X number of files.
Please help me with the entire Batch script.
its an urgent issue u see.

Thanks in anticipation,
Regards,
Jheds



0

Response Number 3
Name: Mechanix2Go
Date: December 20, 2006 at 07:52:10 Pacific
Reply:

This will keep the most recent 5 in the current directory.

You will want to modify it to suit where your backups are.

::== keep5.bat
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%A in ('dir /b/a-d/o-d') do (
set /a kept+=1
echo !kept!
if !kept! geq 6 call :sub1 %%A
)
goto :eof

:sub1
echo del "%*"
goto :eof
:: DONE



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: Jheds
Date: December 21, 2006 at 22:32:44 Pacific
Reply:

Hey Mechanix,

Thank you so much for your valuable time and the solution provided.
It works perfect and I am so grateful to you man :)

thanks again and take care
Jheds


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: HELP Del Files Older Than 15 Days?

How to get files older than 15 days www.computing.net/answers/programming/how-to-get-files-older-than-15-days-/19765.html

Delete Files Older Then x-Days www.computing.net/answers/programming/delete-files-older-then-xdays/15229.html

Deleting a file from many folder www.computing.net/answers/programming/deleting-a-file-from-many-folder/18058.html