I have about 5TB of data stored on Synology NAS servers with a DSM of 6.1+, so bash should be available for use on these systems. The issue is that we are currently archiving this data to external hard drives formatted for NTFS. The main issue is that during the archiving process there appears to be some file conflicts where Linux is case sensitive but Windows is not. So for example:



In linux these are two separate files, but Windows will see them as one file.

The question in hand is that I should be able to figure out which files are conflicts using a tool we used in the past, but there are too many files to rename them manually. These files are spread out across multiple directories going 3 or 4 directories down. If I was able to find out all of the files that are in fact conflicts, what would be the easiest way to rename these files?

The naming really does not matter as long as they do not move from their current location. In the past I have just added a "1" to the end of some of these conflicts, but like I said there are hundreds of conflicts this time.

Are there any recommended tools to find file conflicts like this?


You can get a list of all the files in the current and sub folders using find . | sort -f. The sort will ignore the case so that files with the same name (ignoring case) are next to each other, e.g.:


This should be passed to a script, e.g. Python, which can check each line with the next/previous and if there is a match, you can rename the file, adding understores, or something to it. This should not be too difficult to work out, I imagine.


#!/usr/bin/env python3

import sys

if __name__ == "__main__":
   old_line = ""
   cur_line = ""
   for line in sys.stdin:
      old_line = cur_line
      cur_line = line
      if old_line.lower() == cur_line.lower():
         print("Duplicate found!")
         print("File: {}".format(cur_line))

I called it like this:

find ../ | sort -f | ./rename_files.py
Duplicate found!
File: ../c/modern-approach/test

As there is a second file in that directory called ../c/modern-approach/TEST.

  • Thank you for the response. I like your idea of using the find command to get a list of the files in the directories and sub-directories. – bbelden Jan 16 '19 at 19:59
  • I will have to look into using Python on a Synology NAS server. I know there are some limitations using these NAS servers with what can run on them and what cannot, so it is possible Python will. – bbelden Jan 16 '19 at 20:04
  • Ah yes, I didn't account for the NAS running Python or not. But I'm sure you can do the same with any other scripting language. I'm sure at least one is running on the NAS or can be installed on the NAS. – Tommiie Jan 16 '19 at 20:05
  • So it does appear that Python can be installed and run on Synology NAS servers. This script adds the underscore or random integer to the first or second file? I apologize I am not very familiar with Python scripting. – bbelden Jan 16 '19 at 20:20
  • This script only prints the file name when a duplicate has been found. I don’t know what you want to do with the duplicates. – Tommiie Jan 16 '19 at 20:22

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