File names and Dates from 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
rodre
Premium Member
Premium Member
Posts: 218
Joined: Wed Mar 01, 2006 1:28 pm
Location: Tennessee

File names and Dates from directory

Post by rodre »

Is there a way to insert the file names and dates into a file or table?

I used the DOS "dir" command to get the names, dates (plus a whole lot more information) in a routine but now I would like to parse this info and put it in a file or a table. Just the file name and dates.

Can the folder stage do this?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Any particular reason you keep marking your posts with a Job Type of "TX"? :?

No, the Folder stage can't do that. You'll need to parse it yourself inside the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rodre
Premium Member
Premium Member
Posts: 218
Joined: Wed Mar 01, 2006 1:28 pm
Location: Tennessee

Post by rodre »

Thanks Craig.

There is no option for Enterprise Edition :o

Do you have suggestions on how to parse the data? Here is sample what it looks like:
  • Volume in drive E is SysVol2, Volume Serial Number is AMM1234,, Directory of E:\XData\EEE\BOL,,09/07/2011 08:07 PM 364,636 ByTest.txt,05/31/2011 11:26 PM 66,799 devqdescrip.txt,05/31/2011 11:26 PM 240,031, 75 File(s) 12,738,820 bytes, 0 Dir(s) 110,224,592,896 bytes free
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

rodre wrote:There is no option for Enterprise Edition
Don't need one. Your questions are either for a specific job type (Server, Parallel or TX) and there are forums for each or a "general" question goes in the General forum. I sincerely doubt your questions are related in any way to the TX product, hence my question.

So are you looking for a Server solution or a Parallel solution?
-craig

"You can never have too many knives" -- Logan Nine Fingers
rodre
Premium Member
Premium Member
Posts: 218
Joined: Wed Mar 01, 2006 1:28 pm
Location: Tennessee

Post by rodre »

Got it.

I am more comfortable with Server but if there is an easier solution with Paallel I would give it a try.

Thanks! :D
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

While running a bit late with an answer but for future users, the External Source stage (for parallel jobs) can give you the results of a "dir" command, you then just need to work with the format returned (probably better using the "ls" command to get a decent format)
Satwika
Participant
Posts: 45
Joined: Mon Jan 02, 2012 11:29 pm

How to eliminate summary part :

Post by Satwika »

By using command stage in server job we can get the list of files and dates. In parallel by using External source stage we can get it (as said by kryton).

Here I have an output of file names and dates along with the summary :
My question is how to eliminate the summary part at the top and the bottom (mentioned in red) from output :

Output :

Volume in H
Volume Serial is

Directory of

01/04/2012 09:57 AM .
01/04/2012 09:57 AM ..

07/28/2011 05:24 AM 1_filetest.txt
07/28/2011 02:37 AM 1_test.txt
17 File(s) bytes
3 Dir(s) bytes

Thanks in Advance.
Last edited by Satwika on Fri Jan 20, 2012 5:45 am, edited 1 time in total.
kmsekhar
Premium Member
Premium Member
Posts: 58
Joined: Fri Apr 16, 2010 12:58 pm
Location: Chn

Re: How to eliminate summary part :

Post by kmsekhar »

Satwika, You can eliminate the above rows in execute command stage by

Code: Select all

#below command will remove first 7 lines of a file

sed 1,7d 

and

# delete the last 2 lines of a file
sed 'N;$!P;$!D;$d'
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

But you should have installed MKS toolkit in order to what Muni told work for you.
Or else try your own with dos commands for the same purpose.
if you have mks toolkit, then the below will be more simpler :

Code: Select all

sed -e '1,7d' -e '$d'|sed '$d'
i doubt, if you are using mks toolkit ,you can use "ls" command in stead of "dir"and you will not get these summary details.
pandeeswaran
Satwika
Participant
Posts: 45
Joined: Mon Jan 02, 2012 11:29 pm

Post by Satwika »

Thank you sekhar , it's working.
Can you expand the command :

sed 'N;$!P;$!D;$d'

I read in some forums but unable to understand.

Thanks in Advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Another option - don't generate them. It looks like you were using the DOS "dir" command, if so add the /b option for a "bare" listing and it will only output the filenames.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply