Problem in moving huge number of files

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
sasidhar_kari
Premium Member
Premium Member
Posts: 62
Joined: Wed Dec 08, 2004 2:26 am

Problem in moving huge number of files

Post by sasidhar_kari »

Hi,
I want to move huge number of files from one directory to another directory.
For that i wrote a routine, and when i test this routine it is just moving all the DataStage Repository files to the Target directory instead of moving only files from source path .

Code: Select all

OsType     = 'UNIX'
Move       = 'ls | xargs -t -I {} mv {}'
OsCmd      = Move:' ' : SourceDir:' ':TargetDir
Call DSExecute(OsType,OsCmd,OsOutput,OsStatus)
Ans = OsStatus
SourceDir and TargetDir are the Arguments passing to the routine

Can anyone tell me what's wrong in the code, and how to move files if it is huge .

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

Post by ray.wurlod »

Would it not be better to use a find command with -exec to execute the mv command?

Code: Select all

Move = "cd " : SourceDir : " && find . -exec mv {} " : TargetDir : "\;"
Add filters to limit the search to one level and only to objects of type file (and anything else you need) using other options on the find command.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sasidhar_kari
Premium Member
Premium Member
Posts: 62
Joined: Wed Dec 08, 2004 2:26 am

Post by sasidhar_kari »

Hi Ray,
Thanks for the Response.
When i m using the above given command , i m getting error as An expression term lacks a required parameter.

Code i m executing is

Code: Select all

OsType     = 'UNIX'
Move       = "cd " : SourceDir : " && find . -exec mv {} " : TargetDir : "\;"

Call DSExecute(OsType,Move,OsOutput,OsStatus)
Ans = OsStatus
Here i want to move all the files from the SourceDir to TargetDir

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

Post by ray.wurlod »

That ("all the files") is in fact easier.

Code: Select all

Cmd = "mv " : SourceDir : "/* " : TargetDir
However beware that some UNIX operating systems do not permit mv between file systems. In that case you will need to use cp followed by rm.

Code: Select all

Cmd = "cp " : SourceDir : "/* " : TargetDir : " && rm -f " : SourceDir : "/*"
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