Reading the file names in a directory

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Reading the file names in a directory

Post 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
EFX
nirdesh2
Participant
Posts: 56
Joined: Thu Nov 20, 2008 12:18 pm
Location: Noida

Re: Reading the file names in a directory

Post by nirdesh2 »

You can use file pattern to read all the files in a partcular directory. Using file pattern this can be done.
Nirdesh Kumar
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post 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,
EFX
ColinGorman
Premium Member
Premium Member
Posts: 5
Joined: Fri Oct 12, 2007 2:18 pm

Re: Reading the file names in a directory

Post by ColinGorman »

A simple script will do. Go to the source directory

$ls >> tgt_path/tgt_file
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Reading the file names in a directory

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post 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.
EFX
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply