replacing field in textfile with date

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
PWedig
Newbie
Posts: 5
Joined: Mon May 22, 2006 4:33 pm
Location: Germany
Contact:

replacing field in textfile with date

Post by PWedig » Fri Aug 11, 2006 12:48 pm

Hi,
i have to replace a variable or a line in an textfile (unformated) with the actual date.

into the file there are some lines like:

ORDER: { Nr 1 }
ORDERNUMBER:"";
DATE:%date%;
CURRENCA:"EUR";
RELATION:95;
.............

I want to replace every day the word %date% or the complete line with the actual day date. the result should like this:

ORDER: { Nr 1 }
ORDERNUMBER:"";
DATE:11.08.2006;
CURRENCA:"EUR";
RELATION:95;

There are more orders in the file and at every line, where the variable is %date% the result should be there the actual day date.

I have made some scripts with Macro Scheduler but not any replacing any text into a file. smile....

Please give me any idea....

thanks
Peter

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Aug 11, 2006 1:26 pm

Just use the StringReplace function:

Something along these lines:

Year>yyyy
Month>mm
Day>dd
Let>TheDate=%yyyy%.%mm%.%dd%

ReadFile>...

StringReplace>thetext,%date%,TheDate,thetext
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

PWedig
Newbie
Posts: 5
Joined: Mon May 22, 2006 4:33 pm
Location: Germany
Contact:

Post by PWedig » Fri Aug 11, 2006 4:06 pm

Hello Marcus,

thanks a lot for your help. It's great to get anytime help from you!!!

Here is my result, it's the complet macro because i have had difficulty for the exact defination of every command:

Year>yyyy
Month>mm
Day>dd
Let>TheDate=%yyyy%.%mm%.%dd%

ReadFile>c:\input.txt,file

StringReplace>file,%date%,TheDate,newfile
WriteLn>c:\output.txt,wresult,%newfile%


finished...

best regards

Peter

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts