mv xrags and cp
Marius Gedminas
marius at pov.lt
Mon Jan 15 21:33:44 UTC 2007
On Tue, Jan 16, 2007 at 12:16:53AM +0300, OOzy Pal wrote:
> I am trying to search for all images in all direcotries under olddir
> and cp them to one single direcotry called newdir bearing in mind that
> there might be duplicate files
>
> home/t/1.jpg
> home/g/1.jpg
What do you want done with duplcate files?
> I tried the following but no help
>
> find olddir -name *.jpg |xargs -t -I {} cp {} newdir/{}
>
> I get errors like
>
> cp test/ksi-1253.jpg newdir/test/ksi-1253.jpg
> cp: cannot create regular file `newdir/test/ksi-1253.jpg': No such
> file or directory
>
> note that there is nothing under newdir
If you want the new files to end up in the same directory, do not
mention {} in the cp's destination (and I also suggest you quote
'*.jpg'):
find olddir -name '*.jpg' |xargs -t -I {} cp {} newdir/
If you want to deal with unsafe characters in file names, better do
find olddir -name '*.jpg' -print0 |xargs -0 -t -I {} cp {} newdir/
Actually, in this case you don't win much from using xargs, so you
could just as well use find -exec:
find olddir -name '*.jpg' -exec cp {} newdir/ \;
HTH,
Marius Gedminas
--
How much net work could a network work, if a network could net work?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20070115/d56d2c1e/attachment.sig>
More information about the ubuntu-users
mailing list