Hi chown33,
Firstly let me thank you for your time and effort.
OK here is what I'm trying to do. I have an iTunes library and I wish to put it on my NAS. However when I did I found that my NAS is case sensitive and iTunes could not find some 5,000 songs from 88,000.
Some programs misbehave on case-sensitive file systems. iTunes may be one. Hard to say without knowing versions.
One solution is to create a disk-image on the NAS, format it HFS+ case-insensitive, and put the iTunes library there.
So I used find in terminal to give me a text file with every song listed in the Music folder.
The output of find uses the order that entries are stored in the directory, unless told otherwise (-s option). You didn't show the 'find' command, so I can't suggest anything other than generalized comments.
This appears to be sorted in some particular order, probably the one you suggested.
Nope. It's the order that HFS+ stores directory entries in. The details of the B-tree enetries for the
catalog file are documented, and it's definitely NOT Finder's sorting order. It's not AppleScript's string comparison ordering, either.
If you assumed a sorted order, you made an error. If you're planning to do a binary search, it's mandatory that the list be collated in the same order as the string-comparison function you plan to search with. Close isn't good enough; the collation must be exactly the same.
The obvious solution here is to sort the list into the order needed.
Now what I needed to do was go through every song in the iTunes library and compare it's location to the one in finder.
Manually go through every song? Or with a program? What language is the program written in? I could assume AppleScript, but I could be wrong.
What is it's location "in finder"? Do you mean "in the output of the 'find' command", or do you mean "the sorted result in a Finder window"? I don't know whether you really mean "Finder" (which seems irrelevant) or whether that's a typo for "find" (because the list was produced by 'find').
I needed to do a binary search on my list created from the file and this is where I noticed strange things happening.
As noted above, the same collation order is mandatory.
So what I need is a string comparison function that uses the same collation order as finder did to give the list of files.
Again the ambiguous term "finder". You used "find", not "Finder", to produce the list, as far as I can tell. Accuracy is important in programming.
You also assumed that find's output is sorted in the same collation order that AppleScript's string comparison uses.
The obvious solution at this point, and with no other information, is to assume the list produced by 'find' (not "finder") isn't sorted at all. Sort the list in AppleScript, using AppleScript's own comparison operation, before using it for binary search.