Re: Sync only files with a particular file extension
Tõivo Leedjärv <[email protected]>
| Newsgroups | gmane.network.unison.general |
|---|---|
| Message-ID | <CAALvpZRv1W8mbQ4n6nE_6EsiqyRxr_kcMrwO1fqyK_RpuN497A@mail.gmail.com> |
On Thu, 6 Jul 2023 at 19:44, 'Gilchrist, Michael Aaron' via unison-users <[email protected]> wrote: > > I'm trying to set up a profile to keep all of the files within a directory tree ending in .Rda in sync between computers, but can't find a good way to do this using unison (which I have used for decades for keeping my home directory in sync). Unfortunately, there is no such feature yet. > I've found two threads related to this need to sync based on file extensions on non-unison help forums ((https://urldefense.com/v3/__https://superuser.com/q/1233998/651940__;!!IBzWLUs!S641-o5R6NXzhEbdyu3Af3HK4mDbCVa27-5L4-AzSNDovU_CPoAK1-hpoqlT-691RleYrOBB22GCQ56MWI0d0w$ ) and (https://urldefense.com/v3/__https://superuser.com/q/383376/651940__;!!IBzWLUs!S641-o5R6NXzhEbdyu3Af3HK4mDbCVa27-5L4-AzSNDovU_CPoAK1-hpoqlT-691RleYrOBB22GCQ5493aqmOA$ )), but neither provides a working solution. These answers are pointing in the right direction. There is no other way currently than to use the "ignore" and "ignorenot" preferences with suitable patterns. The key is to know that these preferences work on paths and names, they don't distinguish between directories and files. The idea is to ignore everything, except names ending in. Rda. You need to craft a suitable regular expression for the ignore preference. For example: ignore = Regex .*[.]([^R][^d][^a]|.{0,2}|.{4,}) (you can also specify these preferences on the command line but then you need to quote/escape appropriately for your shell) This will ignore everything that has at least one period in the name (could be the first character), except those that have .Rda at the end. It will not ignore names that have no period in them. This is intentional. The idea is that we don't want to ignore subdirectories and expect those names not to contain periods (see below). The single ignore rule can be split up to several, if you find that simpler: ignore = Regex .*[.].* ignorenot = Regex .+[.]Rda (note that this one is slightly different, also ignoring files/dirs named just ".Rda"; the second pattern can be changed to .*[.]Rda to get the same results as above) (I haven't tested, but ignore = Name *.* and ignorenot = Name ?*.Rda should also work because these are equivalent to the Regex above (the ? is there to require at least one character before the last period, you can drop it if you want)) The side effects of requiring a period in the name are: * all names without any period are still included - this is intentional and is expected to include (mostly) subdirs * all subdirectories with a period in name are ignored To get around these limitations, you can add additional rules, such as these: ignore = Name falsely_included_file1 ignore = Name falsely_included_file2 ignorenot = BelowPath falsely_ignored.dir This is very clunky but it should work. -- To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].