Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm rsync'ing a bunch of files between a Windows and a Linux system. Since not all Windows care about case, some of the files on the Windows system no longer have the same casing as they had on the Linux system. But rsync now treats these files as different and uploads a new copy.

Is it possible to have rsync ignore the case?

share|improve this question
add comment

4 Answers

Normally, Windows ignores case, but preserves it. If your filenames change case, it must be due to some program other than rsync which copied files and mangled the case during the copy. That program is probably misconfigured. Or if you use a Samba server, maybe that is misconfigured. By default, Samba also preserves the case of filenames.

So, maybe you can solve the problem of filenames unexpectedly changing their case.

Then you are left with "only" the problem of case-sensitivity of filters. If that ends up being your case, and you are reluctant to apply the patch suggested by Wim, you can use character classes in the filters.

It's ugly and annoying, but it works:

--exclude="[Tt][Ee][Mm][Pp]/"

or in a filter file:

- Temp/
- temp/
- TEMP/

or the more generic but unreadable:

- [Tt][Ee][Mm][Pp]/ 

If you want to automate the conversion of filter files to this syntax, you can use this perl command:

perl -i.bak -pe 's/([a-z])/[\U$1\E$1]/g' your_rsync-filter.txt

And convert it back to human-readable form with

perl -i.bak  -pe 's/ \[ [A-Z] ([a-z]) \] /$1/xg' your_rsync-filter.txt

(The -i.bak option makes a backup and converts the file in-place instead of to stdout)

At least for filters and include/exclude options, it would be really nice to have a case-insensitive flag in rsync. Until then, the only options seem to be either the patch or the convoluted regex-like syntax.

share|improve this answer
add comment
up vote 2 down vote accepted

Rsync has what they call a "maintained patch" that adds an --ignore-case switch. You need to compile rsync from source for this, and apply ignore-case.patch. You need the patched rsync version on both the local as the remote side.

share|improve this answer
    
Why is this not in the main code? Why leave a patch unapplied? GNU tar has --ignore-case, and can easily switch between case-sensitive exclude files and case-ignored exclude files on the same command line. –  Brendan Byrd Apr 28 '12 at 16:06
    
I'd note that ignore-case.patch resides in the rsync-patches-x.y.z.tar.gz archive (where x.y.z denotes the version number). –  jjlin Jun 10 '12 at 6:39
add comment

There is no specific option to make rsync case-insensitive. Although, NTFS preserves case so you shouldn't have much problem with it. On the other hand, FAT filesystems have more issues with rsync and such a combination should be avoided.

share|improve this answer
add comment

You could try using rsync's fuzzy matching system:

-y, --fuzzy

This option tells rsync that it should look for a basis file for any destination file that is missing. The current algorithm looks in the same directory as the destination file for either a file that has an identical size and modified-time, or a similarly-named file. If found, rsync uses the fuzzy basis file to try to speed up the transfer.

Note that the use of the --delete option might get rid of any potential fuzzy-match files, so either use --delete-after or specify some filename exclusions if you need to prevent this.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.