Page 1 of 1
Edit a text file
Posted: Thu Jan 27, 2011 12:34 am
by Gekseppe
Hi;
I would need some help in writing a task with the following purpose:
1) monitor recursively a folder;
2) in case of new files, for each file, remove the following text from the header (the first 45 chars of the file):
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
3) save edited files in a new folder;
4) delete original files;
5) send new files by mail.
Any help will be really appreciated !
Edit a text file
Posted: Thu Jan 27, 2011 3:26 am
by Oleg
Can you send me an example of such file (oleg (at) robotask.com)?
I think that this job can be solved by using BASIC script (removing of 45 chars from header).
In order to implement the rest steps look at the following actions:
File loop
Text loop
Delete file
Send email
and
File monitor triggering event
Edit a text file
Posted: Thu Jan 27, 2011 3:38 am
by Gekseppe
You got it: thanks !
Edit a text file
Posted: Thu Jan 27, 2011 7:07 am
by Oleg
My example of Basic script is below.
Code: Select all
Sub Main
Dim in_file As String
Dim out_file As String
Dim buf As Byte
Dim i As Long
in_file = RoboTaskApp.ExpandText("{in_file}")
out_file = RoboTaskApp.ExpandText("{out_file}")
'in_file = "C:\incoming\SALE-NO-NA100249-5958.edi.sign"
'out_file = "C:\incoming\SALE-NO-NA100249-5958_1.edi.sign"
Open in_file For Binary Access Read As #1
Open out_file For Binary Access Write As #2
For i =1 To 45 'skip 45 chars
Get #1, ,buf
Next
While True 'skip all CR & LF after 45 chars
Get #1, ,buf
If buf >= 20 Then
Put #2, ,buf
Exit While
End If
Wend
While Not EOF(1)
Get #1, ,buf
Put #2, ,buf
Wend
Close #1
Close #2
End Sub
This script copies the original file and cuts 45 chars from header.
I've sent the example via email.
Of course this task requires BASIC plugin for RoboTask.
Download it here
Edit a text file
Posted: Thu Jan 27, 2011 7:21 am
by Gekseppe
Ouch !!! I'm currently using version 3.1 of Robo Task and Basic Plugin seems to work with version >= 4.1
Do you think there's a way to overcome this ?
Many thanks
Edit a text file
Posted: Thu Jan 27, 2011 8:00 am
by Oleg
Edit a text file
Posted: Fri Jan 28, 2011 3:03 am
by Gekseppe
As usual great support !
Many thanks for your appreciated help: now I just get what I needed !