Page 1 of 1

Rename files based on contents

Posted: Thu Aug 21, 2008 4:40 am
by DavidW
I want to use Robotask (v 2.2) to change a file extension based on the contents of a 'text' file.  The scenario is:
There will be several files in a directory, all called *.edi
I need to rename the files to:
*.CTI if the string "INVFIL" appears in the file, *.CTS if the string "DELHDR" appears in the file and *.CTA if the string "ACKHDR" appears in the file.
I have tried to use the {TextFile(file_name)} variable, but I am unsure as to the correct syntax of this.
Can anyone give some assistance as to how to do this?
Thanks

Rename files based on contents

Posted: Tue Aug 26, 2008 12:54 am
by Oleg
Variable {TextFile()} returns the content of specified file.
You can use this in "If...then" action.

Can you send me your task? my address is oleg (at) robotask.com

Rename files based on contents

Posted: Tue Aug 26, 2008 5:54 am
by DavidW
Oleg
Many thanks for your help in solving this particular issue.
Thanks
David

Rename files based on contents

Posted: Tue Aug 26, 2008 7:17 am
by Oleg
I've placed the task into our examples repository. I think that this task will be interesting for other users too.