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.
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].
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].
10 posts
Page 1 of 1
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 Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
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
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
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
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
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 Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
Replace your Var:
${concat(current_file, '_',currentDate('yyyyMMdd'),'.txt')}
With this:
${concat( string(current_file), '_',currentDate('yyyyMMdd'),'.txt')}
${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
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
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' ) }
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
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
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
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
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),'_',currentDate('yyyyMMdd'),'.txt')}" 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>
10 posts
Page 1 of 1