Rename Remote file

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

LPrendergast

Verified User
Posts: 14
Joined: Tue May 26, 2009 8:54 am

Post by LPrendergast » Wed Jun 17, 2009 11:24 am
Hi , I have a file in the following format:

/XXXXX/YYYYYY/TRAN090603.txt.GO

it is a "TRIGGER FILE" to let us know when a process has completed and the file can retrieved. I also need to rename this file to /OUTPUT/TRINTECH/TRAN090603.txt.processed. Is this possible through GOAnywhere? I was able to add the '.processed' as a suffix, but ideally I would like to remove the '.GO'.

Support_Sai


Post by Support_Sai » Wed Jun 17, 2009 12:01 pm
Yes, it is possible to rename a file TRAN090603.txt.GO to TRAN090603.txt.processed. The Rename task (to rename local files) as well as Rename sub-task under the FTP tasks have advanced options for replacing a part of a file name. These options can be found under the Advanced tab of the rename element. The attributes Search For and Replace With can be used to search for pattern in the file name and replace it with something else. Further more, the search patterns can be specified using simple wildcards or powerful regular expressions. Below are a couple of sample projects that rename a single local file using the Rename task:

Rename a local file using Wildcard pattern:
Code: Select all
<project name="Rename Test" mainModule="Main" version="1.0">
	<description></description>

	<module name="Main">

		<rename inputFile="D:\temp\TRAN090603.txt.GO" searchPattern="*.GO" replaceWith="*.processed" />

	</module>

</project>
Rename a local file using Regex Pattern:
Code: Select all
<project name="Rename" mainModule="Main" version="1.0">
	<description></description>

	<module name="Main">

		<rename inputFile="D:\temp\TRAN090603.txt.GO" searchPattern="\.GO$" patternType="regex" replaceWith=".processed" />

	</module>

</project>
The above project checks the file name to make sure it matches the regular expression "\.GO$". In this pattern "\." is the escape syntax for ".", meaning we search for a period (period in regular expressions has a different meaning, so we had to escape it). Then the pattern needs to match the sequence GO. Finally, the $ tells that there should not be any other characters after GO (end of input match). Then we said, replace the matched substring with ".processed".

The same options are available for renaming remote files using FTP, FTPS or SFTP.
2 posts Page 1 of 1