I am trying to perform a sync using Unison (2.40.102) where I want to ignore all files with a specific extension, say *.ext
, but not ignore the files with this extension if they are in a specific subfolder.
Folder structure:
main_dir
|file.ext
|...
|--sub_dir_1
|more_files.ext
|...
|--sub_dir_2
|even_more_files.ext
|...
|--dir_I_want_to_sync
|sync_this_file1.ext
|...
|sync_this_fileN.ext
|--some_arbitrarily_named_dir
|also_sync_this.ext
|...
|--more_arbitrarily_named_dirs_with_ext_files_in_them
|...
As the folder structure is not constant, I cannot just ignore only specific paths, but have to do this very generally. My idea was to first ignore all the files with the extension *.ext
and then un-ignore the ones below dir_I_want_to_sync
.
However, that is were I am failing to find the right command...
The relevant parts of my profile file look like this:
# Ignore all files with extension *.ext
ignore = Name {.,}*{.ext}
# Try to not ignore the files within the subdirectory (NOT WORKING)
ignorenot = Path */dir_I_want_to_sync/* # 1)
ignorenot = Name */dir_I_want_to_sync/{*/}*{.ext} # 2)
Remarks:
1) Does not do anything, because the files are ignored by their filename, not their path
2) Was meant to reverse the ignore on all the files in dir_I_want_to_sync
, but it does not catch all subfolders.
Is there any way to apply the ignorenot = Name ...
to a file regardless of how deep it is in the directory structure, as long as it is below a directory with a specific name?
(I hope, this was not too confusing. I am happy to clarify!)
ignorenot = Regex */dir_I_want_to_sync/.*\.ext
. Please let me know if this works. – Mike Pierce May 12 '16 at 19:19ignorenot = BelowPath full/path/to/the/dir_I_want_to_sync/with/ext/files/underneath/{.*,*}.ext
. Note that in aPath
the*
matches any string of characters except the/
character, so you can't use it to represent arbitrary paths. – Mike Pierce May 12 '16 at 19:342)
did not work! Thanks for your note. In theRegex
it seems like the initial.
is missing, right? – compare to @Gilles answer. Unfortunately, I could not get theBelowPath
to work, although it seems like a handy option as well! But the Regex did the job, thanks! :) – blsqr May 13 '16 at 09:14