Reading only file name in Datastage Windows

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Reading only file name in Datastage Windows

Post by AmeyJoshi14 »

Hi Experts,

Datastage 9.
O/S Windows 2008 R2
DB SQL Server

We are unable to read just the filename from the sequential file for Datastage windows operating system. Currently the file name is populated as

Code: Select all

D:\LoadInputFile\StageArea\<FileName>.txt
The file path varies in different environment,so we can't hardcode any transformation logic.
Is there command like "basename" where in we can just populate the file name?

Appreciate all your help!

Thanks in Advance!!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can't you use the basename command?

If not, research the tilde options (particularly ~n) for batch script arguments with the DOS shell. Type HELP CALL at a DOS prompt.

Yet another possibility is to treat the pathname as a set of backslash-delimited strings.

Code: Select all

Field(InLink.Pathname, "\", DCount(InLink.Pathname, "\"), 1)
Last edited by ray.wurlod on Thu Jan 17, 2013 4:23 am, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't think you'd need to "hardcode" any transformation logic. I've had to do something similar in the past and put together a generic routine that would count the number of delimiters and then use Field() to take the count+1 delimited field from the full path.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srinivas.nettalam
Participant
Posts: 134
Joined: Tue Jun 15, 2010 2:10 am
Location: Bangalore

Re: Reading only file name in Datastage Windows

Post by srinivas.nettalam »

You can count the number of '\' and take the text after the last '\' using string functions.

Code: Select all

For eg : Field(FileNameColumn,'\',Count(FileNameColumn,'\')+1)
N.Srinivas
India.
Post Reply