- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: file deletion script depending on dates
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2007 04:05 AM
тАО04-18-2007 04:05 AM
Log file names go like this: ex070401.log
I was considering something like this .bat here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=890651
But, this will not do because I need to delete the files accordig to the modification date.
Thank you much.
Edgar.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2007 05:12 AM
тАО04-18-2007 05:12 AM
Re: file deletion script depending on dates
http://www.michna.com/software.htm#DelOld
You can download the source code. Is a tool for removing files based on the age.
While is unsupported, you can check the source code and modify to fit your requirements.
Another tool you can try is "obsolete"
http://users.aol.com/pasacaca/obsolete/obsolete.zip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2007 06:22 AM
тАО04-19-2007 06:22 AM
Solution------------------------------
REM @echo off
for /f "tokens=2,3,4 delims=/ " %%i in ('echo %date%') do (
set /A my_day=%%j-7
set my_month=%%i
set my_year=%%k
)
if %my_day% LEQ 0 set /A my_month-=1
if %my_month%==0 (
set my_month=12
set /A my_year-=1
)
if %my_day% EQU 0 (
if %my_month%==12 set /A my_day=31
if %my_month%==11 set /A my_day=30
if %my_month%==10 set /A my_day=31
if %my_month%==9 set /A my_day=30
if %my_month%==8 set /A my_day=31
if %my_month%==7 set /A my_day=31
if %my_month%==6 set /A my_day=30
if %my_month%==5 set /A my_day=31
if %my_month%==4 set /A my_day=30
if %my_month%==3 set /A my_day=31
if %my_month%==2 set /A my_day=28
if %my_month%==1 set /A my_day=31
)
if %my_day% LSS 0 (
if %my_month%==12 set /A my_day=31+%my_day%
if %my_month%==11 set /A my_day=30+%my_day%
if %my_month%==10 set /A my_day=31+%my_day%
if %my_month%==9 set /A my_day=30+%my_day%
if %my_month%==8 set /A my_day=31+%my_day%
if %my_month%==7 set /A my_day=31+%my_day%
if %my_month%==6 set /A my_day=30+%my_day%
if %my_month%==5 set /A my_day=31+%my_day%
if %my_month%==4 set /A my_day=30+%my_day%
if %my_month%==3 set /A my_day=31+%my_day%
if %my_month%==2 set /A my_day=28+%my_day%
if %my_month%==1 set /A my_day=31+%my_day%
)
set sysdate=%my_year%/%my_month%/%my_day%
set filedate=%my_day%-%my_month%-%my_year%
set my_file = info_%filedate%
echo %sysdate%
echo %filedate%
pause
----------------------
Note that using Powershell would probably be your BEST choice, and it's free from MS.
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2007 06:26 AM
тАО04-19-2007 06:26 AM
Re: file deletion script depending on dates
replace the one section with this: No '+'
--------------------------------------
if %my_day% LSS 0 (
if %my_month%==12 set /A my_day=31%my_day%
if %my_month%==11 set /A my_day=30%my_day%
if %my_month%==10 set /A my_day=31%my_day%
if %my_month%==9 set /A my_day=30%my_day%
if %my_month%==8 set /A my_day=31%my_day%
if %my_month%==7 set /A my_day=31%my_day%
if %my_month%==6 set /A my_day=30%my_day%
if %my_month%==5 set /A my_day=31%my_day%
if %my_month%==4 set /A my_day=30%my_day%
if %my_month%==3 set /A my_day=31%my_day%
if %my_month%==2 set /A my_day=28%my_day%
if %my_month%==1 set /A my_day=31%my_day%
)
----------------------------
I read through me script quickly, and thinking that I had made a mistake, added in the '+' signs. But the number being checked would be negative, so the subtraction will work fine.
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2007 01:13 AM
тАО04-20-2007 01:13 AM
Re: file deletion script depending on dates
Thank you much.
I am testing it.
But this is for sure what I wanted.
I didn't know how to use the tokens in a FOR loop.
Tnks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2007 03:13 AM
тАО05-09-2007 03:13 AM
Re: file deletion script depending on dates
I didn't know how to use the tokens or delims. This is very useful.
What I finally did was this:
@echo off
for /f "tokens=1,2 delims=/" %%i in ('date /t') do (
set _d=%%i
set _m=%%j
)
if %_d% EQU 5 goto 26a31:
if %_d% EQU 6 goto 26a31:
if %_d% EQU 7 goto 26a31:
if %_d% EQU 8 goto 26a31:
if %_d% EQU 9 goto 1a5:
if %_d% EQU 10 goto 1a5:
if %_d% EQU 11 goto 1a5:
if %_d% EQU 12 goto 1a5:
if %_d% EQU 13 goto 1a5:
if %_d% EQU 14 goto 6a10:
if %_d% EQU 15 goto 6a10:
if %_d% EQU 16 goto 6a10:
if %_d% EQU 17 goto 6a10:
if %_d% EQU 18 goto 6a10:
if %_d% EQU 19 goto 11a15:
if %_d% EQU 20 goto 11a15:
if %_d% EQU 21 goto 11a15:
if %_d% EQU 22 goto 11a15:
if %_d% EQU 23 goto 16a20:
if %_d% EQU 24 goto 16a20:
if %_d% EQU 25 goto 16a20:
if %_d% EQU 26 goto 16a20:
if %_d% EQU 27 goto 16a20:
if %_d% EQU 28 goto 21a25:
if %_d% EQU 29 goto 21a25:
if %_d% EQU 30 goto 21a25:
if %_d% EQU 31 goto 21a25:
exit
:26a31
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????26.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????27.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????28.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????29.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????30.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????31.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????26.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????27.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????28.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????29.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????30.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????31.log
exit
:1a5
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????01.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????02.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????03.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????04.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????05.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????01.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????02.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????03.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????04.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????05.log
exit
:6a10
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????06.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????07.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????08.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????09.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????10.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????06.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????07.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????08.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????09.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????10.log
exit
:11a15
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????11.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????12.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????13.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????14.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????15.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????11.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????12.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????13.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????14.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????15.log
exit
:16a20
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????16.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????17.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????18.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????19.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????20.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????16.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????17.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????18.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????19.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????20.log
exit
:21a25
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????21.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????22.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????23.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????24.log
del \\%computername%\e$\LogFiles\SMTPSVC1\ex????25.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????21.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????22.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????23.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????24.log
del \\%computername%\e$\LogFiles\SMTPSVC2\ex????25.log
exit
At least, I got it working.
I still would like to improve it.
If anyone could shed some light as to how to, I would appreciate it.
Tnks.
Edgar.