Using FileLists via SFTP
Defining a project to send a single file though SFTP can be done quickly in the GoAnywhere Project Designer. (See Figure 1)
However there are times when you need to send multiple files over SFTP. For instance, suppose your manager wants you to send .CSV files from a particular folder which is not prefixed with the name “Order”, where the file size is less than 100 KB and the files were created during the previous seven days. In this scenario, you may not know the exact names of the files to send.
This is where a “FileList” variable can help!
A File List variable can contain one or many files that meet your selection criteria. In this example, we will use a File List based on the scenario above.
Before we can SFTP the files to the Target Server, we will need a variable to determine the cutoff date 7 days ago. From the “Miscellaneous” task folder select TimeStamp. Click on the “Next” button and select the “Format” menu option. Enter “LastWeek” as the Output Variable and then “yyyy-MM-dd” for the Pattern. Clicking on the “Date Manipulation” Tab, enter “-7” for the “Day of Month” and then click Save. (See figures 2 and 3)
Add an SFTP task to the project designer. Then click Next and choose to Put files. Define the destination directory of the files and then click Next. Choose to add a file set. (See figure 4)
Now, let’s step through the list and identify the files to add to this FileSet.
Using the browse button next to “Base Directory,” navigate to the folder where the source files are located. (See Figure 5)
By clicking on the “Next” button, select the “Add a Wildcard Filter” option, and then click on “Next” again to select “Include Files.” For the Pattern Prompt, enter the value “*.csv.” This tells the project to select (All) *.CSV files from the source folder identified in the FileSet prompt above. (See Figure 6)
Now, let’s remove any file from that list that begins with “Order”. This is accomplished by right-clicking on the “wildcardfilter” inside the Project Outline and selecting “Exclude Files.” For the Pattern Prompt, enter the value “Order*”. (See Figure 7)
Our next criteria are to remove files that are less than 100 KB from the File List. This can be accomplished by right-clicking on the “fileset” in the Project Outline and selecting “Add a Size Filter.” Click on the “Next” button then select “Exclude Files.” In the From Prompt, enter the number “100 KB”. (See Figure 8)
Within the list selected so far, we only need the files that were created within the last week. To do this, we will use the Date Variable “LastWeek” created in the TimeStamp task above. (See figure 2) Right-click on the “fileset” and a select “Add a Date Filter,” then click on the “Next” button. Click on the “Include Files” option. In the “From Date” prompt, enter ${LastWeek} and then click Save. (See Figure 9)
Reviewing the Source Directory, we find the following files available listed in Figure 10.
Clicking on the “Execute Project,” the Job Log will show you that only 3 of the files met each of the criteria and were uploaded to the Target Server (See Figure 11).
Feel free to contact Linoma Software with any questions or to inquire about our On-Site Professional Services or Training Programs.
Using FileLists via SFTP
Looking for an example project to get you started?
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Using FileLists via SFTP
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696