On Tue, Jun 28, 2005 at 02:22:22PM +0200, [EMAIL PROTECTED] wrote:
> Rsync works fine for me (the rules are reported below) except a point,
> rsync create an empty folders structure that I don'want.

The only way to get rsync to not create directory hierarchies that don't
contain *.txt files is to actually remove the directories from the
transfer, either through more targeted directory includes, or by using
--files-from (though the latter would not make it easy to delete missing
files).

So, instead of the "+ */" rule you would need to maintain some include
rules, perhaps using something like this perl script:

    #!/usr/bin/perl
    use strict;
    my $dir = shift;
    chdir($dir) or die "Unable to chdir to $dir: $!\n";
    print "+ *.txt\n";
    my %hash;
    open(IN, 'find . -name "*.txt" |') or die "Failed to run find: $!\n";
    while (<IN>) {
        chomp;
        s#^\./##;
        next unless s#/[^/]*\.txt$##;
        my $path = '';
        foreach (split(/\//)) {
            $path .= $_ . '/';
            next if $hash{$path};
            $hash{$path} = 1;
            print "+ $path\n";
        }
    }
    print "- *\n";

And use it like this:

  new-script ./source | rsync -avz --delete-excluded --exclude-from=- ./source/ 
./dest

..wayne..
-- 
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to