Thanks for your help. What you provided didn't work for me because that still placed things in subdirectories. I figured it out. This puts it all in the images directory. find /my/phone/root/dir/ \( -path '*Duo*' -o -path '*DCIM*' -o -path '*Pictures*' -o -path '*Camera*' -o -path "*Download*" -o -path "*textgram*" -o -path "*WhatsApp*" ! -path '*.textgram*' ! -path '*.thumbnails*' \) -type f \( -iname '*.jp*g' -o -iname '*.png' -o -iname '*.dng' -o -iname '*.raw' -o -iname '*.raw' \) -exec rsync -uz --progress "{}" /my/backup/directory/for/images/ \; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When you are principled, set standards and stick to them some people will fall out of your life; let them! On Tue, Sep 29, 2020 at 1:33 PM Wayne Davison <wayne at opencoder.net> wrote:> On Tue, Sep 29, 2020 at 7:38 AM Rob Campbell wrote: > >> I would like to sync many subdirectories into one directory with no >> subdirectories. I've tried >> >> rsync -rv --progress --include '*.jp*g' --include '*.png' --include >> '*.dng' --include '*.raw' --include '*.nef' --include 'Duo' --include >> 'DCIM' --include 'WhatsApp' --exclude '*' /my/phone/root/dir/ >> /my/backup/directory/for/images/ >> > > You didn't specify what isn't working as you expect. That command works > fine for the 3 listed dir names as long as you either don't have matching > files inside /my/phone/root/dir (or as long as it's ok to also copy those > files) and as long as there aren't subdirs or files named the same as the 3 > top dirs you included. The latter can be fixed by anchoring your dir names > and making them only match a dir (e.g. --include '/Duo/'). If you want to > have the copy avoid files in the top dir you can either change all the > file-based includes to have a "*/" prefix (such as "--include '*/*.png' > ...") or you can change the dir includes into args and exclude '*/*' > instead of "*". The last option would look like this (I also tossed in -i): > > rsync -riv --progress --include '*.jp*g' --include '*.png' --include > '*.dng' --include '*.raw' --include '*.nef' --exclude '*/*' > /my/phone/root/dir/{Duo,DCIM,WhatsApp} /my/backup/directory/for/images/ > > That assumes you've got bash to do the brace expansion, but you could > change that into 3 arg paths if you need to. You may also want to add --del > if you want rsync to delete inside the 3 listed dirs. > > I'm not sure why you listed an extra command with "NewDir" when it's not > mentioned in the first command. If that is an indication that you really > want to copy all dirs under root/dir (not just the 3 named dirs in the > first command) then you could use an include of "/*/" to match any dir in > the root of the transfer, like this: > > rsync -riv --progress --include '*.jp*g' --include '*.png' --include > '*.dng' --include '*.raw' --include '*.nef' --include '/*/' --exclude '*' > /my/phone/root/dir/ /my/backup/directory/for/images/ > > One last suggestion, I like to make the args shorter by using -f (filter) > commands, so an include example is -f '+ *.png' and an exclude example is > -f '- /*/' (those are identical to the equivalent include/exclude args, so > that's just personal preference). > > ..wayne.. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20200929/0591040d/attachment.htm>
Interesting idea. It isn't something I have ever wanted to do. BTW, if your find is recent use + instead of \;. + replaces {} with however many entries fit in the command line length limit instead of running individual rsync processes for each entry. On 9/29/20 7:46 PM, Rob Campbell via rsync wrote:> Thanks?for your help.? What you provided didn't work for me because that > still placed things in subdirectories. > > I figured it out.? This puts it all in the images directory. > > find /my/phone/root/dir/ \( -path '*Duo*' -o -path '*DCIM*' -o -path > '*Pictures*' -o -path '*Camera*' -o -path "*Download*" -o -path > "*textgram*" -o -path "*WhatsApp*" ! -path '*.textgram*' ! -path > '*.thumbnails*' \) -type f \( -iname '*.jp*g' -o -iname '*.png' -o > -iname '*.dng' -o -iname '*.raw' -o -iname '*.raw' \) -exec rsync -uz > --progress "{}" /my/backup/directory/for/images/?\; > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > When you are principled, set standards and stick to them some people will? > fall out of your life; let them! > > > On Tue, Sep 29, 2020 at 1:33 PM Wayne Davison <wayne at opencoder.net > <mailto:wayne at opencoder.net>> wrote: > > On Tue, Sep 29, 2020 at 7:38 AM Rob Campbell wrote: > > I would like to sync many subdirectories into one directory with > no subdirectories. I've tried > > rsync -rv --progress --include '*.jp*g' --include '*.png' > --include '*.dng' --include '*.raw' --include '*.nef' --include > 'Duo' --include 'DCIM' --include 'WhatsApp' --exclude '*' > /my/phone/root/dir/ /my/backup/directory/for/images/ > > > You didn't specify what isn't working as you expect. That command > works fine for the 3 listed dir names as long as you either don't > have matching files inside /my/phone/root/dir (or as long as it's ok > to also copy those files) and as long as there aren't subdirs or > files named the same as the 3 top dirs you included. The latter can > be fixed by anchoring your dir names and making them only match a > dir (e.g. --include '/Duo/').? If you want to have the copy avoid > files in the top dir?you can either change all the file-based > includes to have a "*/" prefix (such as "--include '*/*.png' ...") > or you can change the dir includes into args and exclude '*/*' > instead of "*".? The last option would look like this (I also tossed > in -i): > > rsync -riv --progress --include '*.jp*g' --include '*.png' --include > '*.dng' --include '*.raw' --include '*.nef' --exclude '*/*' > /my/phone/root/dir/{Duo,DCIM,WhatsApp} /my/backup/directory/for/images/ > > That assumes you've got bash to do the brace expansion, but you > could change that into 3 arg paths if you need to. You may also want > to add --del if you want rsync to delete inside the 3 listed dirs. > > I'm not sure why you listed an extra command with "NewDir" when it's > not mentioned in the first command.? If that is an indication that > you really want to copy all dirs under root/dir (not just the 3 > named dirs?in the first command) then you could use an include of > "/*/" to match any dir in the root of the transfer, like this: > > rsync -riv --progress --include '*.jp*g' --include '*.png' --include > '*.dng' --include '*.raw' --include '*.nef' --include '/*/' > --exclude '*' /my/phone/root/dir/ /my/backup/directory/for/images/ > > One last suggestion, I like to make the args shorter by using -f > (filter) commands, so an include example is -f '+ *.png' and an > exclude example is -f '- /*/' (those are identical to the equivalent > include/exclude args, so that's just personal preference). > > ..wayne.. > >-- ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., Kevin Korb Phone: (407) 252-6853 Systems Administrator Internet: FutureQuest, Inc. Kevin at FutureQuest.net (work) Orlando, Florida kmk at sanitarium.net (personal) Web page: https://sanitarium.net/ PGP public key available on web site. ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._., -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 195 bytes Desc: OpenPGP digital signature URL: <http://lists.samba.org/pipermail/rsync/attachments/20200929/ee46d017/signature.sig>
On Tue, Sep 29, 2020 at 4:46 PM Rob Campbell wrote:> Thanks for your help. What you provided didn't work for me because that > still placed things in subdirectories. >Ah, that's what you were trying to do. Your original email sounded like you just didn't want it to recurse into subdirectories. An easier solution than what you ended up with is to specify a trailing slash after the dir names since that tells rsync you want to copy the content of a directory rather than the directory by name: rsync -riv --progress --include '*.jp*g' --include '*.png' --include '*.dng' --include '*.raw' --include '*.nef' --exclude '*' /my/phone/root/dir/{Duo,DCIM,WhatsApp}/ /my/backup/directory/for/images/ ..wayne.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20200930/d5d45483/attachment.htm>
Except some of those dir have subdir such as WhatsApp and DCIM has multiple subdirs too. I would rather do it all with rsync though. On Wed, Sep 30, 2020, 12:54 PM Wayne Davison <wayne at opencoder.net> wrote:> On Tue, Sep 29, 2020 at 4:46 PM Rob Campbell wrote: > >> Thanks for your help. What you provided didn't work for me because that >> still placed things in subdirectories. >> > > Ah, that's what you were trying to do. Your original email sounded like > you just didn't want it to recurse into subdirectories. > > An easier solution than what you ended up with is to specify a trailing > slash after the dir names since that tells rsync you want to copy the > content of a directory rather than the directory by name: > > rsync -riv --progress --include '*.jp*g' --include '*.png' --include > '*.dng' --include '*.raw' --include '*.nef' --exclude '*' > /my/phone/root/dir/{Duo,DCIM,WhatsApp}/ /my/backup/directory/for/images/ > > ..wayne.. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20200930/58a3bb1f/attachment.htm>