>From your result dump, looks like you're running on a Windows system.
Try this MSDOS batch file:

<code for MSDOS batch file>

@ECHO OFF

SET SavePath=%~1
SET Confirmation=%~2
SET NumberOfReportsToKeep=10
SET ConfirmationMessage=ConfirmDelete
SET ReportsIndex=0
SET ReportsDeleted=0

REM *** Check for existence of required Command Line Parameters, else
EXIT.
IF ["%SavePath%"] == [""] ( GOTO DisplaySyntax )
IF NOT [%Confirmation%] == [] (
        IF NOT [%Confirmation%] == [%ConfirmationMessage%] ( GOTO
DisplaySyntax )
)
IF NOT [%~3] == [] ( GOTO DisplaySyntax )

REM *** Check that the reports parent directory exists.
IF NOT EXIST "%SavePath%" (
        ECHO Save Path not found: %SavePath%
        GOTO DisplaySyntax
) ELSE (
        ECHO Looking for reports to delete in "%SavePath%"
        ECHO.
)

REM *** Loop through directories in report parent folder, passing to
DeleteResult routine.
FOR /F %%n IN ('DIR /A:D /O:G-N /B "%SavePath%"') DO (
        SET LatestBuild=%%n
        CALL :DeleteResult %%n
)

REM *** Confirm number of reports deleted.
ECHO.
IF [%Confirmation%] == [%ConfirmationMessage%] (
        ECHO %ReportsDeleted% reports deleted.
) ELSE (
        ECHO %ReportsDeleted% reports would be deleted.
)
GOTO :eof

REM *** Delete Result if confirmation message supplied and too many
reports found.
:DeleteResult
        SET /A ReportsIndex += 1
        SET ReportPath="%SavePath%\%~1"
        IF %ReportsIndex% LEQ %NumberOfReportsToKeep% (
                ECHO Skipping Report %ReportsIndex%: %ReportPath%
        ) ELSE (
                SET /A ReportsDeleted += 1
                IF [%Confirmation%] == [%ConfirmationMessage%] (
                        ECHO Deleteing Report %ReportsIndex%:
%ReportPath%
                        rmdir /s /q %ReportPath%
                ) ELSE (
                        ECHO Would delete report %ReportsIndex%:
%ReportPath%
                )
        )
GOTO :eof

REM *** Display Syntax for using this script.
:DisplaySyntax
        ECHO.
        ECHO Syntax:    %~nx0 [SavePath] [%ConfirmationMessage%]
        ECHO.
        ECHO    SavePath = Path to reports parent folder.
        ECHO               Enclose with quotes (") if it contains
spaces.
        ECHO    %ConfirmationMessage% = This second parameter is
required to delete.
        ECHO               Otherwise no destructive action is performed.
        COLOR 00
GOTO :eof

</code for MSDOS batch file>

Hope that helps.

Leigh.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marc Guillemot
Sent: Saturday, 9 February 2008 12:01 AM
To: [email protected]
Subject: Re: [Webtest] restrict the number of webtest result backups

Hi,

I guess that Ant standard tasks only allow you to delete dir olders than
a specified date. To delete a special number of folders you probably
need to write a small script.

Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com


Willi Kuhnis wrote:
> Hi,
> 
> I save my webtest results under the result-path in
> a structure like this:
> 
> <tstamp >
>       <format property="savepath" pattern="yyyyMMdd_HHmm"/>
> </tstamp>
> 
> Result:
> 
> 07.02.2008  14:14    <DIR>          20080207_1407
> 07.02.2008  15:03    <DIR>          20080207_1456
> 07.02.2008  15:20    <DIR>          20080207_1506
> 07.02.2008  15:33    <DIR>          20080207_1521
> 07.02.2008  16:24    <DIR>          20080207_1541
> 08.02.2008  08:00    <DIR>          20080208_0800
> 08.02.2008  08:13    <DIR>          20080208_0813
> 08.02.2008  08:14    <DIR>          20080208_0814
> 08.02.2008  08:17    <DIR>          20080208_0817
> 08.02.2008  08:18    <DIR>          20080208_0818
> 08.02.2008  08:24    <DIR>          20080208_0824
> 08.02.2008  08:25    <DIR>          20080208_0825
> 08.02.2008  08:27    <DIR>          20080208_0827
> 08.02.2008  08:33    <DIR>          20080208_0833
> 08.02.2008  08:37    <DIR>          20080208_0836
> 08.02.2008  08:38    <DIR>          20080208_0838
> 
> Now at the start of each webtest run,
> I would like to restrict the number of backups to maybe 10,
> so I want to delete the oldest backups.
> 
> Question:
> Any ideas, how to delete the oldest directories and keep only 10
backups ?
> 
> Thanks
> Willi
> 
> 


_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest



_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to