multiple extentions

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].
8 posts Page 1 of 1

ehersh

Posts: 56
Joined: Mon Sep 26, 2016 12:50 pm

Post by ehersh » Tue Feb 07, 2017 5:23 pm
We have some customers that sends us files that are like filename.txt.txt. We even had one that had 3 .txt on it. The iussue is sometimes when we get that ands load it it escapes our duplicate file check and gets processed with the same records it had before. Is what we are looking at is potentially dropping all TXT's on a file and then slapping just one .txt on it. We cannot do this by looking for the he4 first dot because some file names have dots in it I.E. file.name.txt. We cannot use name without extention because it will drop only the last .txt which will not work if the file has 3 .txt's on it. There are 2 potential possibilities that I can think of.
1. if there is more than 1 .txt cut it down to 1 .txt
2. Drop all .txt's and then just slap one on it.

Any suggestions on the easiest way to do this.

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Feb 07, 2017 11:42 pm
Just loop through the file name looking for the file name "endswith" ".txt"

Just do that until the file does not end with ".txt", then add one and finish.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

ehersh

Posts: 56
Joined: Mon Sep 26, 2016 12:50 pm

Post by ehersh » Wed Feb 08, 2017 12:04 pm
we tried that and got the following error:

Job failed. Job number is '1397289874174'.
[8099 - get file] An unexpected error occurred. Function 'EndsWith': Parameter '1' must be a string value. Function definition: 'EndsWith(haystack, needle[, caseSensitive]) returns boolean'
[/quote]

This is the code we are using:
Code: Select all
<doWhileLoop condition="${Contains(currentfile,&apos;.txt&apos;)}" disabled="false">
				<if condition="${EndsWith(currentfile,&apos;txt&apos;)}">

					<rename inputFilesVariable="${currentfile}" searchPattern="${currentfile}" replaceWith="${currentfile:nameWithoutExtension}" outputFilesVariable="renamefile" version="1.0">
						<fileset dir="<path to>/Inbound" />
					</rename>

				</if>
			</doWhileLoop>

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Feb 08, 2017 1:58 pm
Try this:

<if condition="${ EndsWith( string( currentfile ), 'txt' ) }">
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

ehersh

Posts: 56
Joined: Mon Sep 26, 2016 12:50 pm

Post by ehersh » Thu Feb 09, 2017 11:43 am
I am now getting the following error


Project 'Project Name' failed. Job number is '1397289878761'.
[8099 - Rename] An unexpected error occurred. Function 'Contains': Parameter '1' must be a string value. Function definition: 'Contains(haystack, needle[, caseSensitive]) returns boolean'

In this code
Code: Select all
					<rename searchPattern="${ Contains( currentfile, txt ) }" replaceWith="${currentfile:nameWithoutExtension}" outputFilesVariable="renamefile" version="1.0">
						<fileset dir="<path to>/Inbound" />
					</rename>

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Thu Feb 09, 2017 12:46 pm
See the example above again ... you did not include the "string" function as stated. Please review, retry and let us know.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

ehersh

Posts: 56
Joined: Mon Sep 26, 2016 12:50 pm

Post by ehersh » Thu Feb 09, 2017 12:57 pm
Project 'Project Name' failed. Job number is '1397289878959'.
[8099 - Rename] An unexpected error occurred. Function 'Contains': Parameter '1' must be a string value. Function definition: 'Contains(haystack, needle[, caseSensitive]) returns boolean'
Code: Select all
	<rename searchPattern="${EndsWith(String(currentfile), &apos;txt&apos; ) }" replaceWith="${currentfile:nameWithoutExtension}" outputFilesVariable="renamefile" version="1.0">
						<fileset dir="<path to>/Inbound" />
					</rename>

ehersh

Posts: 56
Joined: Mon Sep 26, 2016 12:50 pm

Post by ehersh » Wed Feb 15, 2017 9:32 am
It has tested successfully, thank you for your help. In case anyone else needs to do something similar I included the code.
Code: Select all
<forEachLoop itemsVariable="${get_file}" currentItemVariable="currentfile">

			<setVariable label="Get file name" name="filename" value="${currentfile:name}" version="2.0" />

			<if label="IF file has .txt" condition="${EndsWith(String(filename), &apos;.txt&apos;)}">

				<setVariable label="get position" name="position" value="${PositionOf(filename, &apos;.txt&apos;)}" version="2.0" disabled="false" />


				<setVariable label="renamed file" name="testname" value="${Substring(filename, 1, position-1)}" version="2.0" disabled="false" />


				<rename inputFile="${currentfile}" newName="${testname}" version="1.0" />
8 posts Page 1 of 1