Home Knowledge Articles IBM Cognos 8 BI Script to delete old transformer mdc files
Follow us on Twitter


Countries

50.1%United States United States
7.6%India India
7%United Kingdom United Kingdom
5.1%Australia Australia
4.8%Canada Canada

Visitors

Today: 34
Yesterday: 111
Last Week: 3357
This Month: 9186
Last Month: 16191
Total: 382839


Script to delete old transformer mdc files Print E-mail
(2 votes, average 4.00 out of 5)
Written by CognosLord   
Tuesday, 30 March 2010 10:19

Product:

 

Cognos BI 8.1 and higher

 

 

Problem:

 

How do I erase old transformer mdc cube files from a folder?

 

Cause:

 

In many cases you create a new powerplay cube file every night with Cognos transformer. Then you get a lot of MDC files in a folder. But you want the old cube files to be erased.

In the creation process of the powercubes MDC file you add the date in the name as;

 

BudgetA20100218.mdc

 

Solution:

 

Create a batch file that contains below text,

Place the script file erasecube.cmd in the same folder as the mdc cube files.

Run the script as part of the cube build process.

The script will erase all MDC files that do not have today’s date in the name.

 

…………………..

 

Rem checks today date and format it to the variable currentdate

set currentdate=%date:~3,4%%date:~8,2%%date:~11,2%

 

rem List the cubes to be deleted

dir /B *.mdc | find /V "%currentdate%" > delete.list

 

rem Deleting the cubes

for /F %%j in (delete.list) do del /Q %%j

 

rem Deleting the list of used above

del /Q delete.list

 

..............................

Ensure you test the script before you use it in production.

 

You must change the line “set currentdate=%date:~3,4%%date:~8,2%%date:~11,2%”

to get it to work with your regional settings on the computer.

 

MS-DOS function date:~3,4  is 3 the position before first character to use, and 4 is the number of characters to use in the date string.

 

In a MS-DOS prompt on the Cognos server;

Check today’s format by type DATE /T in the prompt

 

You may see the date as 2010-03-26

 

Then you need to change the currentdate line to reflect this

 

set currentdate=%date:~3,4%%date:~8,2%%date:~11,2%

 

Above may give that variable currentdate is “0-0326”.

You change the line to be like below to get the right format.

 

set currentdate=%date:~0,4%%date:~5,2%%date:~8,2%

 

You can check by run above command in MS-DOS box

 

Then enter %currentdate% to see the value in the variable.

 

D:\temp>%currentdate%

'20100326' is not recognized as an internal or external command,

Operable program or batch file.

www.cogknowhow.com

Comments

Please login to post comments or replies.
 
 

Login

For more content en features!



CogKnowHow Newsletter

Season's Greetings


Receive HTML?

Polls

How many users are working on your Cognos environment?