Renaming files on remote server

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
2 posts Page 1 of 1

hatchet

Posts: 1
Joined: Wed Sep 19, 2018 10:04 am

Post by hatchet » Wed Sep 19, 2018 10:38 am
Hi,

I wonder if someone could help me with this, I've been trying various options to get this to work and I either get a syntax error or the job executes but nothing is renamed.

I have a remote FTP server with files in "\myfolder" matching "M*.TXT".
There may be 1 file there at a given time, or multiple files.
I want to rename them all when the job executes to "R3*.TXT".
I don't care what the rest of the filename is, so the 'M' can be preserved or overwritten as long as the filename begins "R3"

This is what I currently have and executes without errors but nothing is renamed - I have test files in the correct location.
I have test files in place but I don't know if it's failing due to the naming syntax, the folder syntax or what.
Code: Select all
<ftp resourceId="Server" version="1.0">
			<rename searchPattern="M*.TXT" patternType="wildcard" replaceWith="R3*.TXT">
				<fileset dir="\myfolder">
					<wildcardFilter>
						<include pattern="M*.TXT" />
	                        </fileset>
			</rename>
		</ftp>

Support_Andy

Posts: 8
Joined: Thu Feb 16, 2017 11:03 am

Post by Support_Andy » Fri Sep 21, 2018 9:07 am
How to use the rename command on a FTP server
See attachment for associated images to steps below
rename_FTP_forum.docx
Step by Step FTP instructions
(158.54 KiB) Downloaded 920 times
1. Start with a timestamp task

2. List the files on the FTP server that match the format to rename

3. Use a For Each Loop to Iterate over the new ${fileList} variable created from step 2

4. Rename using the Input Files Variable ${cur} and use Search Pattern of M*.txt and replace with R3*_${CurrentTimeMillis()}.txt

NOTE: The replace action will fail if a file with that name exists on the remote server. For this reason, the addition of the millisecond timestamp can overcome that limitation.

5. Folder contents before rename
"M9901.txt ","Mandy 9.txt", "M123.txt"
6. Folder contents after rename
"R399101_1537535252915.txt", "R3andy 9_1537535252949.txt", "R3123_1537535252888.txt"
2 posts Page 1 of 1