Problem with renaming a file

Wayne Davison wayned at samba.org
Tue May 23 16:48:55 GMT 2006


On Mon, May 22, 2006 at 08:58:43PM -0700, Rajesh Prabhu wrote:
> Now that im able to get the attribute of a file(whether its hidden or
> not) using attrib.exe, is there a way to transfer such hidden files
> from windows machine to linux machine with a prepended "."?

To do this with the stock rsync, you'd need to script the renaming
yourself somehow.  For instance, create a local copy of the files,
rename the ones that are hidden, and then rsync from the copied files.
Or, rename them in-place, copy them, and then rename them back again
(if that would not disrupt anything).

Another alternative is an old patch named fname-convert.diff.  This
patch was last present in the 2.6.6 release.  I didn't like the design
for a few reasons, including how it would typically need to run a new
convert command for every name.  However, for what you're doing it would
be perfect.  If you created a script that would read a filename on
stdin, check if the file is hidden or not, and then output either the
unchanged filename or the name prepended with a dot, you could use a
patched version of rsync with such a script to accomplish what you want.

Finally, if you want to roll your own, look for the routine make_file()
in flist.c: after the routine copies the name into the "thisname"
buffer, you could modify it however you wish, but you should probably
protect the tweaking-code via "if (am_sender)" so that it doesn't affect
--delete processing when receiving files.

..wayne..


More information about the rsync mailing list