WriteLn> to beginning of file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

WriteLn> to beginning of file

Post by Aaron » Tue Jul 17, 2007 6:33 am

How do I WriteLn> to beginning of file, Not the end

Thanks
Aaron

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

Post by Marcus Tettmar » Tue Jul 17, 2007 7:31 am

Write the string to a new file, then append the existing file to it, overwriting the existing file in the process. Delete the temporary file. So:

WriteLn>temp_new_file,r,This is a new line
AppendFile>temp_new_file,ActualFile,ActualFile,r
DeleteFile>temp_new_file
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Jul 17, 2007 2:40 pm

Here is another way to accomplish what you asking for.

I use the time to demonstrate that the script will write the new entry to line 1.

Code: Select all

GetTime>TIME
ReadFile>%TEMP_DIR%\~TempMSFile.txt,result
let>K=%TIME%%CRLF%%result%
DeleteFile>%TEMP_DIR%\~TempMSFile.txt
WriteLn>%TEMP_DIR%\~TempMSFile.txt,r,%K%
exe>%TEMP_DIR%\~TempMSFile.txt

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