1

I have the following scenario:

I have a remote server that every week gets loaded with 2 files, these files have the following name format:

"FINAL_NAME06Apr16.txt" and "FINAL_NAME_F106Apr16.txt"

The part in bold is fixed everytime, but the date changes, now, I need to pick, copy to another directory and rename these files. but I'm not sure about how to pick the name of the files to variables to operate with them as I need to put different name to each file.

How can I proceed? I' pretty sure it has to be done with naming a variable with an expression, but I don't know how to do that part.

I think I need some function to calculate the rest of the filename, I believe maybe some approach could be to first rename the part "FINAL_NAME_F1" and then rename the "FINAL_NAME" since some wildcards will pick both if don't do it that way?

Cheers.

Baldie47
  • 1,148
  • 5
  • 16
  • 45

1 Answers1

3

You can calculate the date but why go through that complexity?

A Foreach (File) Loop Container, FELC, will handle this just fine. Add two of them to your control flow.

The first one will use a file mask of FINAL_NAME_F1*.txt. Inside that FELC, use a File System task to copy/move/rename the file to your new location.

That first FELC will run, find the target file and move it. It will then look for the next file, find none and go on to the next task.

Create a second FELC but this one will operate on FINAL_NAME*.txt It's crucial that the first FELC run first as this file mask will match both FINAL_NAME_f1-2019-01-01.txt and FINAL_NAME-2019-01-01.txt. By ordering our operations as such, we can reduce the complexity of the logic required.

Sample answer with a FELC to show where to plumb the various bits

billinkc
  • 59,250
  • 9
  • 102
  • 159