Count of files to be transferred

Matt McCutchen matt at mattmccutchen.net
Thu Apr 29 23:54:27 MDT 2010


On Fri, 2010-04-30 at 12:13 +0700, Ryan Joseph wrote:
> I'm making a GUI for rsync and having some problems getting a reliable
> indication of the files that will be transferred (so I can make a
> progress bar from the results). I didn't see rysnc offered this so my
> plan has been to get a list of files that will be transferred and
> count them as rsync reports them using the -v option thus getting a
> ratio I could make a progress bar from.

> The problem is I don't see there is a way to have rsync tell me which
> files will be transferred so I can count the list.

Rsync determines which of the files in the file list need a data
transfer as it goes, so the only way to get the count in advance is to
do a separate dry run.  Then you could take the "Number of files
transferred" from --stats output.

Alternatively, you could base the progress bar on the total number of
entries in the file list.  The --progress option does this, but it won't
be accurate if incremental recursion is enabled.

> I tried using the --list-only option to count the files first but I
> can't get it to report the same number of files as are actually
> transferred when I don't use the option. For example the same command
> with --list-only is listing 8000 files and when I remove the command 0
> files are transferred (which is correct). Shouldn't the command using
> --list-only report 0 files also as that's how many will be
> transferred?

No.  --list-only lists all the source files and does not use the
destination at all.  I think it was originally intended for listing
files on an rsync daemon.  It can also be useful for testing.

-- 
Matt



More information about the rsync mailing list