I have x number of files that are being downloaded from an FTP server to the temp workspace. The prefix denotes which customer the file will need to be sent to. My plan was to sort the files by prefix into temporary folders with in the temp workspace. Once in their specific folder i need to remove the prefix before sending to customer.
ex. 001_B012R00962D20140602T2014060154044.txt
001_ being the prefix
Open to any suggestion to accomplishing the same result.
Sort file based on file prefix
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
- Support_Jon Offline
- Support Specialist
- Posts: 62
- Joined: Thu Jul 19, 2012 9:15 am
- Location: Ashland, NE
- Contact:
Re: Sort file based on file prefix
David,
If the order of the files when retrieved from the FTP server aren't in the order that you want, then some extra work will be needed to put them in the order you need. Currently, there is no built in way to sort a file list... but this functionality is on the road map for a future release of GoAnywhere Director. In the meantime you will have to follow this basic outline on how to pull it off.
1) As you process each row, you can use the substring function against the file name to retrieve the file name without the prefix.
2) Alternatively, prior to processing rowset, you can use the Modify Rowset task (requires version 4.6.0 or later) to build an updated rowset that contains the existing values and an output file name exactly how you want them to be. Then from there, you can process the resulting output rowset.
If the order of the files when retrieved from the FTP server aren't in the order that you want, then some extra work will be needed to put them in the order you need. Currently, there is no built in way to sort a file list... but this functionality is on the road map for a future release of GoAnywhere Director. In the meantime you will have to follow this basic outline on how to pull it off.
- create your file list
- write the file list values to a temporary database(file name, full path)
- retrieve the values from the temporary database (order by file name)
- process the resulting rowset as needed.
1) As you process each row, you can use the substring function against the file name to retrieve the file name without the prefix.
2) Alternatively, prior to processing rowset, you can use the Modify Rowset task (requires version 4.6.0 or later) to build an updated rowset that contains the existing values and an output file name exactly how you want them to be. Then from there, you can process the resulting output rowset.
Re: Sort file based on file prefix
Thanks for the reply.
In regards to the sort, I'm not sorting so the files are in a certain order. I'm sorting, moving, files into their respective temporary folder based on the prefix. Once in the folder I would remove the prefix and upload to customer. I was going to take the file list and loop through it.
In regards to the sort, I'm not sorting so the files are in a certain order. I'm sorting, moving, files into their respective temporary folder based on the prefix. Once in the folder I would remove the prefix and upload to customer. I was going to take the file list and loop through it.
- Support_Jon Offline
- Support Specialist
- Posts: 62
- Joined: Thu Jul 19, 2012 9:15 am
- Location: Ashland, NE
- Contact:
Re: Sort file based on file prefix
Ok. My details above still apply. when you do the move, you could specify the destination file name without the prefix... or you can move them, then when you rename the files, you can change the name at that point.dchmax wrote:Thanks for the reply.
In regards to the sort, I'm not sorting so the files are in a certain order. I'm sorting, moving, files into their respective temporary folder based on the prefix. Once in the folder I would remove the prefix and upload to customer. I was going to take the file list and loop through it.
Either way you'll still have to loop through the list to accomplish what you want.
Re: Sort file based on file prefix
My understanding is to rename the file I need to first assign the original name to a variable. I'm having difficulties getting this information from destination files variable. I've created a forEachLoop to go through the variable but I get the following error.
[9008 - rename ] Attribute 'newName' may only be specified when renaming a single file.
Maybe I'm going about it the wrong way.
[9008 - rename ] Attribute 'newName' may only be specified when renaming a single file.
Maybe I'm going about it the wrong way.
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Sort file based on file prefix
On the Rename Task, there are 2 options for the input file name... "Input File" & "Input Files Variable"
Then, there is only one "New Name"
If you have a single file (File Name), then typing the new name in the "New Name" field will work. If you're passing in an "Input Files Variable" (aka, multiple files) then you will need to give it a name in the "New Name" field, but you will also need to add a Prefix or Suffix (from the Advanced Tab) so that it gives each file name a unique value. By default, the Task does not rename multiple files to the same file name.
GoAnywhere automatically assumes that if you use the Input Files Variable, that there are multiple files. Whether there is just one or not.
Then, there is only one "New Name"
If you have a single file (File Name), then typing the new name in the "New Name" field will work. If you're passing in an "Input Files Variable" (aka, multiple files) then you will need to give it a name in the "New Name" field, but you will also need to add a Prefix or Suffix (from the Advanced Tab) so that it gives each file name a unique value. By default, the Task does not rename multiple files to the same file name.
GoAnywhere automatically assumes that if you use the Input Files Variable, that there are multiple files. Whether there is just one or not.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696