Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Perhaps you could do this using a list of include patterns instead, and use <code>--delete-excluded</code> (which does as the name suggests)? Something like:</p> <pre><code>rsync -r --include-from=&lt;patternlistfile&gt; --exclude=* --delete-excluded / dest/ </code></pre> <p>If filenames are likely to contain wildcard characters (<code>*</code>, <code>?</code> and <code>[</code>) then you may need to modify the Python to escape them:</p> <pre><code>re.sub("([[*?])", r"\\\1", "abc[def*ghi?klm") </code></pre> <p><strong>Edit:</strong> Pattern-based matching works slightly differently to <code>--files-from</code> in that <code>rsync</code> won't recurse into directories that match the exclude pattern, for reasons of efficiency. So if your files are in <code>/some/dir</code> and <code>/some/other/dir</code> then your pattern file needs to look like:</p> <pre><code>/some/ /some/dir/ /some/dir/file1 /some/dir/file2 /some/other/ /some/other/dir/ /some/other/dir/file3 ... </code></pre> <p>Alternatively, if all files are in the same directory then you could rewrite the command slightly:</p> <pre><code>rsync -r --include-from=&lt;patternlistfile&gt; --exclude=* --delete-excluded /some/dir/ dest/ </code></pre> <p>and then your patterns become:</p> <pre><code>/file1 /file2 </code></pre> <p><strong>Edit:</strong> Thinking about it, you could include all directories with one pattern:</p> <pre><code>/**/ </code></pre> <p>but then you'd end up with the entire directory tree in <code>dest/</code> which probably isn't what you want. But combining it with <code>-m</code> (which prunes empty directories) should solve that - so the command ends up something like:</p> <pre><code>rsync -m -r --delete-excluded --include-from=&lt;patternfile&gt; --exclude=* / dest/ </code></pre> <p>and the pattern file:</p> <pre><code>/**/ /some/dir/file1 /some/other/dir/file3 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload