I'm triing since few days to do this. So sorry if my question looks stupide, but i've tried.
I have to get picture from a folder (who is updated automaticly and with subfolder) with theirs extensions (i'm ok on that) and this files have to me copied in a folder where a website base on php will edit them (rename and creating of and xml file).
The problem is because of the rename function of the script when I do again the copy, it put it back and the script rename it... I've tried rsync with --backup with a folder --backup-dir define, but it's still doesn't work, it's still sending file in backup folder desite their presence in the incremental folder.
Here is my code. You can laugh on them, i'm not a pro shell script coder.
When I lauch just the find and rsync functions, it doesn't put all my files in the incremental folders (and the extensions). I have to run the functions twice to get all files in incremental folder. This the command.
find '/home/name/picture' -name '*.jpg' | while read FILE ; do rsync --backup --backup-dir=incremental --suffix=.old "$FILE" /var/www/media ; done
Thank in advance for your help.
PS; A little more thing, would be to replace '.' with a 'space' just after the *.jpeg copy. My php script have some problem to define file with with comma because of the extension. I'm finking about a command with 'find' like I like just below with a 'sed' function? It's good?
---------- Post updated at 01:41 PM ---------- Previous update was at 01:02 PM ----------
I miss something, I have to grab image from all folder and sub folder to one folders. I tried your script and it keep the directory.
I get also this for xargs
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
Thanks for your answer. I just try it. The files are copy but nothing go in 'incremental' folder, so when I edit the name of my copied files and do again the command the files with name's changed are copied again.
It's strange because rsync doesn't do what I want. No suffix and no backup-dir...