Page 1 of 1

Delete log files using batch script

Posted: Fri Feb 02, 2018 10:21 am
by Mark RMBC
Hi all,

When deleting log files in TM1 I tend to either use wildcardfilesearch or a batch script, but with the batch script I set up a .bat file manually and simply reference it in the TI process.

I noticed that the bedrock method seems to create the .bat file on the fly and then delete it. I therefore thought I would try this approach but I have encountered a problem. It doesn’t delete the log files!

When I look in the .bat file I see the following:

"forfiles -p "E:\FTPS ROOT" -s -m tm1s*.log -d -3 -c "cmd /c del @path" "

The start and end quotes are the problem because when I remove them the .bat file works.

My TI code is as follows (please note that I am not yet using executecommand in the ti. The ti simply creates the .bat file at this stage):

Code: Select all

vLogDays = NumbertoString(-3);
vLogDir = '"E:\FTPS ROOT"';
vPath = cellgets('adm_Assumptions', 'General', '06_Export_Folder') | '\';
vServer = cellgets('adm_Assumptions', 'General', 'Server_Name');
sFileName = vPath | 'Delete Log Files' | vServer | '.bat';
ASCIIOUTPUT( sFileName, 'forfiles -p ' | vLogDir | ' -s -m tm1s*.log -d ' | vLogDays | ' -c "cmd /c del @path" ');

Re: Delete log files using batch script

Posted: Fri Feb 02, 2018 10:52 am
by orlando
Hi Marc,

DataSourceASCIIQuoteCharacter=''; is your friend.

When set like this, the quotes will not be set.

Best regards,

orlando

Re: Delete log files using batch script

Posted: Fri Feb 02, 2018 11:17 am
by Mark RMBC
Yes that worked.

Thanks Orlando, much appreciated!