Page 1 of 1

Pulling FTP File Without Name

Posted: Mon Apr 21, 2014 4:30 pm
by cderendinger
I want to be able to pull a file from an FTP server but the naming scheme is random. How do I set FTP to pull any file that is there?

Re: Pulling FTP File Without Name

Posted: Wed Apr 23, 2014 8:49 am
by Support_Chris
Hi cderendinger,
In order to use FTP to pull any and all files that are located in a directory, you'd utilize a fileset on the FTP Get task. You can add a fileset to the FTP Get by clicking on the NEXT button of the FTP Task screen, after you've specified the destination directory.

Here is an example project that does exactly what you're looking for:
Code: Select all
<project name="FTP Get ALL" mainModule="Main" version="2.0">

	<module name="Main">

		<ftp resourceId="My PC" version="1.0">
			<get destinationDir="C:\test\FTP Test\" whenFileExists="overwrite">
				<fileset dir="/upload/" />
			</get>
		</ftp>

	</module>

</project>


In this project, I'm retrieving all files that are located in the /upload/ directory of my FTP server.


Thanks,
Chris

Re: Pulling FTP File Without Name

Posted: Thu Apr 24, 2014 7:46 am
by cderendinger
In this FTP folder there is 4 files and I am only wanting to retrieve the .xlsx and then delete it. The other 3 files I need to be able keep in the FTP folder.

Re: Pulling FTP File Without Name

Posted: Thu Apr 24, 2014 8:34 am
by Support_Chris
Hi cderendinger,
If you have a specific file you need to grab, you'll drill down to the wildcard filtering portion of the fileset. To do this, click NEXT from the FILESET element and Add a Wildcard Filter, then NEXT and Include Files. In your case, you'll be filtering for *.xlsx. Be sure to define an output variable in the processed source files variable field under the Output Variables tab of the Get Files sub-task.

After the Get Files sub-task, add a Delete Files sub-task to the FTP task and specify the output variable that you created earlier in the Input Files Variable field.

Here is a sample project XML that suits your requirements:
Code: Select all
<project name="FTP Get ALL" mainModule="Main" version="2.0">

	<module name="Main">

		<ftp resourceId="My PC" version="1.0">
			<get label="getFile" destinationDir="C:\test\FTP Test\" whenFileExists="overwrite" processedSourceFilesVariable="getFile">
				<fileset dir="/upload/">
					<wildcardFilter>
						<include pattern="*.xlsx" />
					</wildcardFilter>
				</fileset>
			</get>
			<delete label="Delete getFile" inputFilesVariable="${getFile}" />
		</ftp>

	</module>

</project>

In this example, we're getting all files that end with the extension .xlsx in directory /upload/ on the FTP server. Then after the Get sub-task, we're deleting the file(s) that were downloaded from the remote FTP server, before disconnecting from the source server.


Thanks,
Chris