On a Mac, how can I find all files on a NTFS partition that have the same name, given case *in*sensitivity?

3

2

Here's the deal, I have a huge mess of files on an external drive that is formatted as NTFS. I wish to copy all of these files onto my MacBook Pro.

NTFS, like sane filesystems, is case sensitive. HFS is not.

There is, somewhere in the mess of tens of thousands of files and directories, one or more 'duplicates' in the eyes of HFS. Theses are preventing me from copying the entire directory of data onto my mac.

(MacOSX rather unhelpfully throws a general error explaining the problem, but not the exact file. It also doesn't give you an option to skip)

What is the best approach to solve this? Does anyone know a tool that can find files and directories that have the same case-insensitive name?

--Edit--

So I did a cp -i and left it running overnight with the intention of waking up and seeing it stuck on a duplicate, but when I woke up it had finished! However, the resulting directory had 13,906 items while the original has 13,914, so it sounds like cp either doesn't recognise files that are the same given case insensitivity, or it ignores them even with -i.

SCdF

Posted 2010-04-02T07:11:49.277

Reputation: 293

1Out of curiosity, how did you end up with these dupes? Have you been using the POSIX subsystem under Windows? – Hugh Allen – 2010-04-02T08:10:00.193

But Mac OS X doesn't use HFS. It uses HFSX, a variant of HFS+ with optional - wait for it - case sensitivity. – None – 2010-04-02T10:46:35.387

@Graham, awesome, can I turn it on without formatting my entire drive? – SCdF – 2010-04-02T15:28:50.790

@Hugh, it's a bunch of data from a previous Linux install, but on NTFS for various reasons (it's the easiest to get working on all 3 OSs for a start) – SCdF – 2010-04-02T15:30:40.660

NTFS, like sane filesystems, is case sensitive. HFS is not. no, NTFS supports case sensitive, but on Windows it's turned off because programs would complain. HFS+ also has case sensitive and case insensitive version. HFS virtually doesn't exist nowadays – phuclv – 2016-04-03T16:07:45.327

Answers

5

I don't know if this is the best approach, but the following command does what you want and lists you all files and directory entries for which duplicate case insensitive names exist:

find /path/to/check -type f -o -type d | tr A-Z a-z | sort | uniq -d

What it does is, find all files and directories in /path/to/check, makes the output lowercase, sorts those entries (required since uniq only compares adjacent lines) and filters to only show duplicate lines i.e. duplicate file or directory entries.

Example: If I wanted to check my Bootcamp Volume on OS X for duplicates I would open Terminal.app and execute

find /Volumes/BOOTCAMP/ -type f -o -type d | tr A-Z a-z | sort | uniq -d

Lukas Loesche

Posted 2010-04-02T07:11:49.277

Reputation: 686

2

I haven't used it, but iPartition claims to be able to nondestructively convert between HFS+ (case-insensitive) and HFSX (case-sensitive).

Gordon Davisson

Posted 2010-04-02T07:11:49.277

Reputation: 28 538

1

can I turn it [case sensitive HFSX] on without formatting my entire drive

You may create a case sensitive disk image on Mac OS X which can be mounted as a normal hard drive volume.

# cf. http://codesnippets.joyent.com/posts/show/8617
IMAGE="${HOME}/Desktop/Case Sensitive Test.dmg"
VOLNAME="Case Sensitive Test"

hdiutil create "${IMAGE}" -size 10m -fs HFSX -volname "${VOLNAME}" -layout NONE

hdiutil attach "${IMAGE}"

cd "/Volumes/${VOLNAME}"
touch foo.txt Foo.txt
open .
ls -l [Ff]oo.txt
stat -f "inode: %i  --  name: %N" [Ff]oo.txt

cd ~
hdiutil detach "/Volumes/${VOLNAME}"

taco

Posted 2010-04-02T07:11:49.277

Reputation: 11

1

I use Double Commander, which is a Total Commander alternative for Mac OS X. It has the same look and feel as TC and the same Search function. Easy Find is good and convenient, but I found this quicker most of the time. I just looked up all my *.iso files quickly on my NTFS partition.

Viktor

Posted 2010-04-02T07:11:49.277

Reputation: 11

0

From Mac OS 10.3 on the command newfs_hfs -s will create a case-sensitive new file system.

Hugh Allen

Posted 2010-04-02T07:11:49.277

Reputation: 8 620

That's good to know for future reference, but I can't create a new filesystem, I'm very much stuck with the one I have. – SCdF – 2010-04-02T15:29:45.577