Using FileLists via SFTP

Looking for an example project to get you started?

Using FileLists via SFTP

Postby Support_Rick » Thu Jan 23, 2014 1:13 pm

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)

Figure_01.png
Figure_01.png (19.51 KiB) Viewed 509 times


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)

Figure_02.png
Figure_02.png (17.63 KiB) Viewed 509 times

Figure_03.png
Figure_03.png (23.04 KiB) Viewed 509 times


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)

Figure_04.png


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)

Figure_05.png
Figure_05.png (20.16 KiB) Viewed 509 times


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)

Figure_06.png
Figure_06.png (21.28 KiB) Viewed 509 times


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)

Figure_07.png
Figure_07.png (22.3 KiB) Viewed 509 times


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)

Figure_08.png
Figure_08.png (23.34 KiB) Viewed 509 times


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)

Figure_09.png
Figure_09.png (24.45 KiB) Viewed 509 times


Reviewing the Source Directory, we find the following files available listed in Figure 10.

Figure_10.png
Figure_10.png (11.51 KiB) Viewed 509 times


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).

Figure_11.png
Figure_11.png (6.94 KiB) Viewed 509 times


Feel free to contact Linoma Software with any questions or to inquire about our On-Site Professional Services or Training Programs.
Rick Elliott
Sr. Product Specialist
(402) 944.4242
(800) 949-4696
Support_Rick
Support Specialist
 
Posts: 162
Joined: Tue Jul 17, 2012 2:12 pm

Return to Example Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron