How do move large number of files ?

p.echols at comcast.net p.echols at comcast.net
Thu Apr 15 02:28:01 UTC 2010


----- "Fred Roller" <fred at fwrgallery.com> wrote:

> On 04/13/2010 03:09 PM, MirJafar Ali wrote:
> 
> Hello,
> 
> I have very huge number of files in one directory that I wish to move
> to some other folder and
> the standard "mv" just screames
> 
> crash-06:~/DataSet$ mv file* SFiles
> bash: /bin/mv: Argument list too long
> 
> 
> Can someone suggest what is may be a good solution. of course picking
> one by one is ruled out.
> 
> Mir
> 
> 
> 
> You can try:
> 
> cd [directoryof source]
> for i in *; do mv $i [fullpathtodestination]/; done
> 
> or safer option is (provided you have the disk space)
> 
> cd [directoryof source]
> for i in *; do cp -a $i [fullpathtodestination]/; done
> # once done and confirmed do: (you can use a wildcard just be /very/
> careful.)
> rm [pathtosource]/[files]

If the spource and destination are on the same partition:

How about same as above but: cp -al . . .
 
the 'l' will hard link instead of copy, so very little extra space.  When you delete the source, you are just deleting the link.  I don't know enough about it to know the behavior if source and destination are on different partitions (or for example different computers like a desktop and a server)  I'd be interested in the answer if anyone can enlighten


--PE




More information about the ubuntu-users mailing list