Scenario: Data source is a flat file and we want to load this data into the target. The problem is the source file name keeps on changing.
Here we go:
- Use a pre-session script that creates a file list.
Windows
dir /b part_of_file_name*.txt > FILELIST_NAME.LST
UNIX
ls part_of_file_name* > FILELIST_NAME.LST
- In Workflow Manager edits the session task and go to the Mapping tab.
- Select the flat file source.
- Under Properties, enter the list file name (“FILELIST.LST”).
Under Source filename change the value for Source file type to Indirect.
I found an alternative Informatica offical website: It uses a wildcard in the name of a source file in a PowerCenter session, use the Command option:
In the Workflow Manager, edit the session task and go to the Mappings tab.
Select the Flat File Source Definition and click the Properties tab.
Set the Input type as “Command” and the Command type as “Command generating File list”.
In the Command option, enter the command to list the files.
The Command used depends on the operating system.
Windows
On Windows, due to a known issue, the command will need to be added to a batch file.
Example
The following commands can be added to a batch file to list the files in “bare” mode:
@echo off
cd C:\Informatica\PowerCenter8.6.1\server\infa_shared\SrcFiles
dir /b file_name*.txt
In this case the batch file is called file_list_test.bat.
The following would be added to the command option:
$PMSourceFileDir\file_list_test.bat
UNIX
On UNIX, use the ls command in the Command option.
Example
ls $PMSourceFileDir/file_name*
These commands generate a file list from the source file directory of all files that start with the same name.
When the session runs, the flat file reader reads each file as it reads the file names from the command.