mv xrags and cp

OOzy Pal oozypal at gmail.com
Tue Jan 16 16:49:06 UTC 2007


On 1/16/07, Marius Gedminas <marius at pov.lt> wrote:
> 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?
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFFq/M4kVdEXeem148RAiXAAJ9+TmT/JnLhqZXTmmwaAoJrNKbxDgCbB8+t
> aRoME4Og2sUPh+zism2V58Q=
> =XiTR
> -----END PGP SIGNATURE-----
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
>
>

>What do you want done with duplcate files?
there not duplicate in content but they have the same name.

This command is good
 find olddir -name '*.jpg' -exec cp {} newdir/ \;

how can I make the above command rename the file in the format of

date +%s%N.jpg

to make sure that each file gets a unique name?

-- 
OOzy
Kubuntu-Edgy




More information about the ubuntu-users mailing list