Page 1 of 1

Reading the file names in a directory

Posted: Tue Apr 28, 2009 3:26 am
by efxuser
Hi All,
I need to load names of all the files(in a directory) into a flat file. I have searched the forum n found some useful posts like.. viewtopic.php?t=118304&highlight=read+file+name
kcbland wrote:If you simply need file names in a directory why not use a Sequential stage with a filter command to do a directory listing? Why all of the mess with the Folder stage?
If, I use a sequential file stage with filter command to do a directory listing..What value should be there for File Name Property..

Thanks

Re: Reading the file names in a directory

Posted: Tue Apr 28, 2009 4:54 am
by nirdesh2
You can use file pattern to read all the files in a partcular directory. Using file pattern this can be done.

Posted: Tue Apr 28, 2009 6:04 am
by efxuser
Hi Nirdesh,
Thanks for your response. I have to read the file names only, no need to read the contents of the file..

Thanks,

Re: Reading the file names in a directory

Posted: Tue Apr 28, 2009 6:21 am
by ColinGorman
A simple script will do. Go to the source directory

$ls >> tgt_path/tgt_file

Re: Reading the file names in a directory

Posted: Tue Apr 28, 2009 6:43 am
by chulett
efxuser wrote:If, I use a sequential file stage with filter command to do a directory listing..What value should be there for File Name Property..
The stage will combine the two fields automatically, first the filter command followed by the filename, so you could put the full path to the directory in the filename and just the "ls -1" or whatever listing command you need in the filter itself.

If you need / want to put everything in the filter, then put "/dev/null" in the filename.

Posted: Tue Apr 28, 2009 6:59 am
by efxuser
Craig,
I will test it and let you know.

ColinGorman,
I have to do it in a datastage job.

Thankyou all for your responses.

Posted: Tue Apr 28, 2009 4:13 pm
by ray.wurlod
There was a recent webinar on precisely this topic.
Go to www.dsxchange.net/webinar_training.html and look for the title "Files and DataStage Job Sequences"