I am trying to write a script to copy all files in a directory tree to another directory, using find command. However, some files have the same name as other. Since I am not interested in file names at all, I thought that the simplest solution would be to give to the copies progressive numbers as names. I tried with this command:
i=0
find . -iname "*.jpg" -exec cp {} $DEST_DIR/$i ; i=$i+1;
however, this command obviously won't work, as -exec runs a subshell in which i variable is not defined. Has anyone got some idea to do this, preferably with find? Is there any other better way to do it?