You can use a command to generate a list of source files for a mapping. You can use a valid DOS or UNIX command, batch file, or shell script.
Data Integration
reads each file in the list when the task runs.
Use a command to generate a file list when the list of source files changes often or when you want to generate a file list based on specific conditions. For example, you can use a command to generate a file list from all files in a directory or based on the file names.
Use the following guidelines when you generate a file list through a command:
You must enter Windows commands that use parameters such as "/b" in a batch file.
You must enter fully qualified file paths in each command, batch file, and shell script.
You cannot use an in-out parameter for the file list command.
UNIX Example with Shell Script
You need to extract data from parts lists that are stored on a Linux machine. The parts lists are text files that are stored in the
/home/dsmith/flatfile/parts
directory.
The following table shows the command that you enter in the Source transformation and the contents of the corresponding shell script:
Command
Shell Script (parts.sh)
/home/dsmith/flatfile/parts/parts.sh
cd /home/dsmith/flatfile/parts
ls *.txt
Windows Example with Batch File
You need to extract data from sales records that are stored on a Windows machine. The sales record files are stored in the
C:\SalesRecords
directory and use the naming convention
SalesRec_??-??-2017.txt
.
The following table shows the command that you enter in the Source transformation and the corresponding batch file contents:
Command
Batch File (SalesSrc.bat)
C:\SalesRecords\SalesSrc.bat
@echo off
cd C:\SalesRecords
dir /b SalesRec_??-??-2017.txt
Example without Shell Script or Batch File
You can also generate a file list through a command instead of through a batch file or shell script. For example, the following command generates a file list that contains one file named source.csv: