adding date stamp

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

ehersh

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

Post by ehersh » Wed Oct 05, 2016 12:49 pm
I am going into a folder and pick up multiple files using a wild card. For example the wild card says test*.*. That will pick up test1.txt, test2.txt etc. However when I deposit them into another folder I need to put a date stamp on so file names are test1_yyyymmdd.txt, test2_yyyymmdd.txt etc. I can generate the date stamp I am having the problem is I can prefix the entire file with the date-time stamp or suffix it. Is there a way to insert the date stamp prior to the .txt? So instead of test1.txt_yyyymmdd I would have test1_yyyymmdd.txt.

Support_Rick

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

Post by Support_Rick » Fri Oct 07, 2016 3:42 am
When you pick up the multiple files using a wild card, you're creating what's called a "FileList Variable".

Using this FileList variable, you can loop through the files individually and process them 1 for 1, or you can process them as a whole using the FileList Variable.

in this case, you'd need to process them individually, allowing you to rename them as you go. This allows you to take full advantage of the File Attributes associated to the FileList variable.

Is Pseudo terms, you would do something like:

CreatefileList MyFileList
ForEach MyfileList -> ThisFile
Copy File ${ThisFile} to ${ concat( ThisFile:nameWithoutExtension, '_', currentDate('yyyyMMdd'), '_', ThisFile:extension ) }
EndForEach
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 » Fri Oct 07, 2016 7:22 am
Thank you

ehersh

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

Post by ehersh » Mon Oct 17, 2016 11:52 am
I have tried that numerous times, I am getting the following error:
Project 'Project Name' failed. Job number is '1397289360302'.
[8099 - copy to archive] An unexpected error occurred. Function 'Concat': Parameter '1' must be a string value. Function definition: 'Concat(text, text[, text...]) returns string' Original expression: concat(current_file, '_',currentDate('yyyyMMdd'),'.txt').


This is my copy statement where my destination is resource:smb://directory/home/EDI\Goanywhere_testing/Inbound/${concat(current_file, '_',currentDate('yyyyMMdd'),'.txt')}

current file is the variable for the current file in the for each loop

Support_Rick

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

Post by Support_Rick » Mon Oct 17, 2016 1:19 pm
Replace your Var:

${concat(current_file, '_',currentDate('yyyyMMdd'),'.txt')}

With this:

${concat( string(current_file), '_',currentDate('yyyyMMdd'),'.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 » Mon Oct 17, 2016 4:33 pm
now it is telling me resource:smb://resource/dir/Goanywhere_testing/Inbound/wrongfile1.txt_20161017' not found but that directory does exist I have trried numerous modifications all to no avail.

Support_Rick

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

Post by Support_Rick » Mon Oct 17, 2016 5:07 pm
Are you sure it's not supposed to be:

resource:smb://resource/dir/Goanywhere_testing/Inbound/wrongfile1_20161017.txt

instead of:

resource:smb://resource/dir/Goanywhere_testing/Inbound/wrongfile1.txt_20161017

If that's the case, look into your file attributes (you can search for those in the help). Then, review the attribute "nameWithoutExtension".

Then try something like:

${ concat( string( current_file:nameWithoutExtension ), '_', currentDate('yyyyMMdd'), '.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 » Tue Oct 18, 2016 8:11 am
I did get through that OK now it appears it can't find the attribute nameWithoutExtension

ERROR [8099 - renamed file] An unexpected error occurred.
Method 'getNameWithoutExtension' or 'isNameWithoutExtension' not found on class 'com.linoma.dpa.util.FileList'.
Original expression: concat(string(get_file:nameWithoutExtension),'_',currentDate('yyyyMMdd'),'.txt').

Below is how I coded it.

${concat(string(get_file:nameWithoutExtension),'_',currentDate('yyyyMMdd'),'.txt')}

get_file is the file list variable

ehersh

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

Post by ehersh » Tue Oct 18, 2016 10:11 am
this is the xml
Code: Select all
<project name="tstdatefilenameesh" mainModule="Main" version="2.0" logLevel="verbose">
	<description>test claim file movements</description>

	<module name="Main">

		<createWorkspace version="1.0" />


		<timestamp label="timestamp" version="1.0">
			<format outputVariable="year" pattern="yyyy" />
			<format outputVariable="month" pattern="MM" />
			<format outputVariable="day" pattern="dd" />
		</timestamp>


		<createFileList label="get file" fileListVariable="get_file" numFilesFoundVariable="count_files" version="1.0" disabled="false">
			<fileset dir="<path to>/Goanywhere_testing/Inbound/">
				<wildcardFilter>
					<include pattern="wrong*.*" />
				</wildcardFilter>
			</fileset>
		</createFileList>

		<forEachLoop label="loop" itemsVariable="${get_file}" currentItemVariable="current_file" currentIterationVariable="current_file" disabled="false" />

		<setVariable label="renamed file" name="renamed_file" value="${concat(string(get_file:nameWithoutExtension),&apos;_&apos;,currentDate(&apos;yyyyMMdd&apos;),&apos;.txt&apos;)}" version="2.0" disabled="false" />


		<copy label="copy to archive" sourceFilesVariable="${current_file}" destDir="<path to>\Goanywhere_testing/Inbound/test" whenFileExists="rename" processedSourceFilesVariable="current_file" destinationFilesVariable="${renamed_file}" version="1.0" logLevel="debug" disabled="false" />

	</module>

</project>

ehersh

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

Post by ehersh » Wed Oct 26, 2016 7:51 am
This has been resolved. I did not have my copy within the for each loop and needed to add a workspace.
10 posts Page 1 of 1