I need to keep in sync a very large directory structure (a few hundreds GB) between a Windows machine and a Linux machine. I'm using rsync to do the copy because it automatically ignores unchanged files and is more effective at copying changed files (copying only the difference).

The problem I have is that some applications running on the Windows file system like to generate all kinds of metadata files that I don't want to copy. As all these files are hidden using Windows file attributes, I thought it would be very helpful to simply instruct rsync to ignore such files. But the rsync man page does not offer any such option.

Currently I mount the Windows file system using SMB. When I use a console to list the files in the directory (using ls -l), it lists all the files including hidden files, but when I use nautilus to list the files it recognizes that some are hidden files and only shows them to me if I enable "show hidden files". So I'm not sure if rsync can even see that Windows files are hidden.

Any suggestions will be really helpful.

3 Answers 3


To get the DOS attributes into Linux you will need to edit your smb.conf file.

There are two different ways to import Windows attributes.

The first option is to set map hidden = yes which will mean that hidden files on Windows will have the world execute bit set on Linux. For this to work you must also have at least 001 in your create mask.

The other option is to set store dos attributes = yes which will mean that the Windows attributes will be stored in an extended attribute in the Linux file system called user.DOSATTRIB.

rsync doesn't have the ability to filter files based on either normal or extended attributes but it can exclude a list of files that you have prepared in some other way. You can use the find command to create this list based on Unix attributes. The version of find I have doesn't seem to support extended attributes but it might still be possible to use the -exec option in find to get extended attributes of all your files and filter on them.

Since find can filter on normal Unix permissions, if you chose the world execute bit option then find . -perm -001 will find all of the hidden files in your mounted Windows filesystem. You can put this list in a file and then use rsync --exclude-from=FILE to exclude those files from your rsync.

  • Thanks for the answer. I currently use gvfs to mount the remote system, which does not have that option, but your answer is the most detailed and will probably apply to many other situations. I will possibly switch to Samba so I can use your solution. Thanks again.
    – Guss
    Nov 16, 2009 at 12:11

I don't believe rsync has any insight into which files are marked "Hidden" on the Windows fileshare. Do the files have anything else in common, such as a naming format? You can use the --exclude or --exclude-from options to pattern-match filenames not to copy. (The --exclude-from=xyz option loads these exceptions from a file, whereas the --exclude option specifies them on the command line.)

  • Currently I use --exclude, but the list is rather long and its cumbersome to manage (even in a separate file). I think the "hidden file" semantics is made available through the SMB mount because Nautilus handles them perfectly.
    – Guss
    Nov 12, 2009 at 14:53

I don't have an answer for you, but I don't think rsync is the right place to be looking. I would either try to find something in the sharing options on the windows side, or a mount.cifs options.

It might be possible using ACL extensions, but there is nothing in traditional unix permissions that makes a file hidden. It is just hidden if has a period as the first character in the file / dir name.

  • Changing things on the Windows side is not really doable (otherwise I would have just gone and deleted the files before the transfers). I don't want to make files hidden - just understand how I can tell that they are, as I mentioned some application on the Linux side can tell the difference somehow.
    – Guss
    Nov 12, 2009 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .