Delete unwanted files and results folders from LoadRunner script folders

It’s a common complaint of IT chaps supporting performance test teams that their script folders are large (especially if you’ve been running scripts with logging enabled for debugging purposes). Lots of files can be deleted before you save or archive your scripts which saves disk space and generally keeps things tidier.

The batch file (tidyup.cmd) attached to this article can help you to tidy up your LoadRunner script folder. It deletes unwanted log files and output files. The following files are deleted.

mdrv.log
mdrv_cmd.txt
options.txt
pre_cci.c
.ci
combined_.c
output.txt
debug.inf
All files with .idx extension
All files with .bak extension
The Result1 folder and it’s contents

 

It is also possible to delete RecordingLog.txt file in the scriptdata folder. If you delete this file, it will not affect the script’s replay. However, you will not be able to see the information about what happened during recording.

 

Batch file – tidyup.cmd Description of action
IF EXIST %temp%blankfile.txt  del %temp%blankfile.txt /q
IF EXIST %temp%FilesDeleted.txt  del %temp%FilesDeleted.txt /q
IF EXIST %temp%FoldersDeleted.txt  del %temp%FoldersDeleted.txt /q
IF EXIST %temp%BadParms.txt  del %temp%BadParms.txt /qtype nul > %temp%blankfile.txt
type nul > %temp%FilesDeleted.txt
type nul > %temp%FoldersDeleted.txt
type nul > %temp%BadParms.txt

del *.idx /s >> %temp%FilesDeleted.txt
del mdrv*.log /s >> %temp%FilesDeleted.txt
del mdrv.txt /s >> %temp%FilesDeleted.txt
del options.txt /s >> %temp%FilesDeleted.txt
del *.ci /s >> %temp%FilesDeleted.txt
del combined_*.c /s >> %temp%FilesDeleted.txt
del output.txt /s >> %temp%FilesDeleted.txt
del debug.inf /s >> %temp%FilesDeleted.txt
del *.bak /s >> %temp%FilesDeleted.txt

for %%d in (h) do (
for /f “delims=” %%a in (‘dir/s/b/ad “%CD%result*”‘) do (
echo “deleted %%a” >> %temp%FoldersDeleted.txt
rd /s /q “%%a”
)
)

rd result1 /s /q

 

findstr /S “:\” *.prm > %temp%BadParms.txt

fc %temp%FilesDeleted.txt %temp%blankfile.txt > nul
if errorlevel 1 “Notepad.exe” “%temp%FilesDeleted.txt”

fc %temp%FoldersDeleted.txt %temp%blankfile.txt > nul
if errorlevel 1 “Notepad.exe” “%temp%FoldersDeleted.txt”

fc %temp%BadParameters.txt %temp%blankfile.txt > nul
if errorlevel 1 “Notepad.exe” “%temp%BadParms.txt”

IF EXIST %temp%blankfile.txt  del %temp%blankfile.txt /q
IF EXIST %temp%FilesDeleted.txt  del %temp%FilesDeleted.txt /q
IF EXIST %temp%BadParms.txt  del %temp%BadParms.txt /q

These lines delete any existing files from previous runs of this batch file.These lines create blank files for later file comparisons.These del functions delete the unwanted LoadRunner files and pipe any output into the %temp%FilesDeleted.txt file.

This “for loop” deletes any sub-folders called result1 and pipes any output into the %temp%FoldersDeleted.txt file.

This deletes the local result1 directory if it exists

This function looks for explicit file paths rather than relative file paths in the .PRM files and writes them to the %temp%BadParameters.txt file.

If FilesDeleted.txt exists, open it in Notepad.exe wo we can see the names of deleted files.

If FoldersDeleted.txt exists, open it in Notepad.exe wo we can see the names of deleted folders.

If BadParameters.txt exists, open it in Notepad.exe wo we can see the names of parameters that don’t use relative file paths (and are less portable).

Finally delete the superfluous temporary files.

 

This batch file can be run either from within a script folder, or from a top-level folder containing multiple LoadRunner scripts. If run in a top level folder it loops through all sub-folders deleting files and results folders as it goes. In both cases, the list of deleted files and folders is displayed using notepad.exe .

Some of my colleagues prefer to have a copy of the tidyup.cmd batch file in all their script folders and some prefer ro run it from the top level folder. If you want a copy of tidyup.cmd in all your sub-folders the copytidy.cmd file can be used to copy the batch file to multiple sub-folders.

Batch file – copytidy.cmd Description of action
for %%d in (h) do (
for /f “delims=” %%a in (‘dir /a:D /b’) do (
copy %%a tidyup.cmd
)
)
For each sub folder identified by the dir /a:D /b command.
Copy the tidyup.cmd command into the folder.