Mac OS X 10.5.3 (Leopard): How to reproduce the random file renaming bug in Spotlight

Posted by Pierre Igot in: Macintosh
May 30th, 2008 • 2:42 pm

Following more prompting from intrigued Betalogue readers after my post about Mac OS X 10.5.3 yesterday, I decided to see if I could try and reproduce the random file renaming bug reliably.

After more experimenting, I think that I am actually able to reproduce it fairly reliably. I am not entirely sure. But I seem to be able to reproduce it most of the time on my machine, and I tried on my wife’s MacBook Pro (which runs Mac OS X 10.5.2), in her user environment, and I got the same result.

Now, this is a dangerous bug, which randomly renames files that are listed in a Spotlight search results window. So in order to reproduce this bug yourself, you might want to create a dummy folder with dummy files, so that you don’t run the risk of damaging valuable files.

Here is the scenario that, on my machines at least, can be used to reliably reproduce the random file renaming, without risking damage to valuable files.

Create a folder called “Test” in your home folder.

With TextEdit, create a text-only file containing the word “George” and save it under the name “Alan.txt” in the “Test” folder.

Still with TextEdit, create another text-only file containing the word “George” and save it under the name “Albert.txt” in the same “Test” folder.

Finally, still with TextEdit, create another text-only file containing the word “George” and save it under the name “Alfred.txt” in the same “Test” folder.

So now you have a folder named “Test” which contains three plain text files named “Alan.txt,” “Albert.txt” and “Alfred.txt,” all of which contain the word “George”:

File Renaming Bug 1

Now, in a Finder window, select the “Test” folder and type the word “George” in the search field. Then click on the button with the name of the current folder, i.e. “Test,” in order to restrict the search for “George” to the “Test” folder only.

You should have the following three results:

File Renaming Bug 2

By default, the results are automatically sorted based on the value of their “Last Opened” attribute, i.e. the file that was last opened appears at the top of the list, and then the second last one, and so on. So the exact order of the three files will depend on the order in which you created and saved them earlier on.

Now click on the second item in the list (i.e. “Alfred.txt” in my case) once to select it:

File Renaming Bug 3

Then click on it twice to open the file in TextEdit. Make sure you don’t click on the file icon, but on the file name. A reader has pointed out that, if you double-click on the file icon, the file name does not become editable.

If you double-click on the file name, however, Mac OS X opens the file in TextEdit, but also makes its name editable in the Finder window in the background, which is the first visual manifestation of this bug:

File Renaming Bug 4

While in TextEdit, type a letter in the document window for the “Alfred.txt” document that you’ve just opened, then press command-S to save the changes, command-W to close the document, and command-Tab to return to the Finder. (You can also use the mouse for these steps. It shouldn’t make any difference.)

If the bug affects you the same way it affects me, then you’ll get the following alert message:

Alert message

The exact name of the file that this message refers to might be different, as it seems to depend on the order in which the files are sorted in the search results window.

If it does not work for you with that file, i.e. if you can’t reproduce the bug by selecting and then double-clicking on the second file in the list and doing the other steps, then try the first one or the last one and do the same thing: select it, double-click on it to open it in TextEdit, add a character to it, save it, and return to the Finder.

Upon returning to the Finder, you should get the error message.

Please note that you only get the error message because the file that the Finder is attempting to rename behind your back is in the same folder as the one whose name it wants to use. Since you cannot have two files with the same name in the same folder, you get the error message. But if the two files were in two different folders, Mac OS X would just randomly change the name of the other file without telling you, and there is no way to tell which file it has renamed either.

Now, it is possible that these steps won’t work for you the first time around. Even now, when I repeat the steps on the same files, I sometimes do not get the random renaming, depending on which of the three files I click on, and on the order in which they are sorted in the Spotlight search results window sorted by Last Opened date. (This order keeps changing, of course, since I keep opening the files by double-clicking on them.)

But if you are intrigued by this bug and want to try and reproduce it, I suggest you try at least a few times, with any of the three files, until you get the error message. Hopefully (so to speak!) you’ll be able to reproduce it, and maybe you’ll even be able to fine-tune the scenario and identify one additional requirement that makes it possible to really reproduce it 100% of the time, every time. (I can quite figure it out myself, but I am quite convinced that it involves the changing order of the files in the window.)

Feel free to comment on this post if you can (or cannot) reproduce the bug. And if you feel, like me, that this bug is too serious to remain unaddressed by Apple’s engineers (which is the case so far), then please submit a bug report to Apple which clearly outlines the steps above!


8 Responses to “Mac OS X 10.5.3 (Leopard): How to reproduce the random file renaming bug in Spotlight”

  1. lex says:

    I am able to consistently recreate this bug using your steps.

  2. sol says:

    This is definitely new in 10.5. I am still using 10.4 and I could not recreate this bug (if that helps you narrow it down). Like you, Pierre, I feel that this bug is very serious and should be addressed by Apple. I have enough trouble keeping track of the name changes I initiate let alone having my computer doing it in the background without my knowing.

  3. jbravo556 says:

    Well, I got the error message, but I couldn’t get the random rename even after 50+ attempts with BBEdit and TextEdit.

    Let’s say I’m trying with ‘Albert.txt’. The error message would state that I can’t use the file name ‘Albert.txt’ because it’s already in use. So the name doesn’t change for me. The Finder simply gives an error message that trying to rename the file ‘Albert.txt’ to ‘Albert.txt’ cannot be done. I got this error about 1 time for each 6 or seven attempts. In one of the attempts the error message was ‘cannot open the alias Albert.txt because the original item cannot be found’ but deselecting the file, selecting it and double clicking its name didn’t produce the alias error anymore.

    Do you have any auto-typing, auto-correcting utility active on your system? Anything that takes keyboard input before the active application get it? If you do, maybe it’s re-routing the input to the Finder. I have Grammarian X on mine, so that may affect my results too (although, turning it off didn’t change the outcome).

    So I got the same error message that you’re getting, but I couldn’t successfully replicate your random rename problem. It’s on an Intel iMac, with 10.5.3.

  4. Pierre Igot says:

    sol: Yes, the bug is a new one introduced by 10.5. It is tied to the new results window, which did not exist in this form in 10.4.

    jbravo: I specifically indicated that, in order for the random name changes to happen, the results need to be in different folders. If the results are in the same folder, you get the error message, because OS X cannot have two files with the same name in the same folder. But the core issue remains that OS X is attempting to rename a file without the user’s consent. The fact that you are getting the alert is proof that the bug is occurring on your machine too. It just cannot complete the name change because of the name conflict, but there is no reason for OS X to even attempt a name change here. If you want to see a name change happening, modify the above scenario by storing each text file in a different subfolder, and reproducing the same steps. Then you’ll see the name change in its full glory.

  5. jbravo556 says:

    You’re absolutely right.

    In my experiment, I thought that the file being renamed is the file whose name is highlighted for editing. So the name staying the same didn’t seem like a big deal.

    However, after I moved one of the files into a different directory and started double clicking that, the second file in the list was getting renamed, not the one that you double click.

    That is a strange bug indeed.

    Good thing I don’t really use the Finder. I use Path Finder instead.

  6. Pierre Igot says:

    It’s not just strange, it’s downright dangerous. It doesn’t take much—a simple Spotlight search and exploration of the search results—to trigger it, and when it occurs it changes the names of files behind your back in a totally untraceable way. It can even change a folder (in the search results list) into a file! I have seen an entire folder turned into a Pages document. Of course, when I tried to open the pseudo-Pages document, I got an error in Pages, and I then used the “Show Package Contents” command to explore the insides of that pseudo-Pages document and discovered it contained all kinds of files!

    I was able to change that pseudo-Pages document back into a folder, but unfortunately since there is no way to trace the random name changes who knows how many other files or folders have been affected on my hard drives. Anything that might have shown up in a Spotlight search results window at any point is susceptible. It is very worrying.

    I have no idea how Mac OS X chooses the file that it randomly renames. But it is definitely a file other than the one selected in the Spotlight search results window. If you have 50 files/folders listed in your Spotlight search results window, any of them could be affected.

    As for where this bug might come from, my sense is that it’s because the Spotlight search results window in the Finder is actually only a pseudo-Finder window, a “hack” that Apple uses to make a totally different beast look like a regular Finder window, when it is actually more like a 10.4-era Spotlight window with additional Finder-like features.

    For example, the Spotlight search results window does not have the same view options as regular Finder windows. It also is the only type of Finder window that is affected by the visible “editable name in background” bug. If you select an item in a regular Finder window and then double-click on its name, Mac OS X does not make its name editable in the background.

    So this leads me to think that Spotlight search results windows follow their own rules, and this major bug is hidden somewhere inside those rules. Apple needs to fix it ASAP. But they will only do so if they get substantial bug reports from many different users. So please submit yours, with all the detailed steps.

  7. deb says:

    My mac has this bug and it is driving me crazy! Thankyou for explaining what is probably happening. I am a student and doing alot of writing and research. Many of my files have been randomly renamed and I have deleted them thinking they were duplicates! ARGHHHHH! Is there any way to fix this problem? I have not contacted Mac though do have tech support still- will do that soon.
    Any input appreciated- thanks!

  8. Pierre Igot says:

    If you have tech support (and time to spare!), you can always try to contact them and explain how to reproduce the bug and how damaging it is. Feel free to give them a link to this page.

    Otherwise, the only option is to get a free registration with the Apple Developer Connection and submit the bug in a bug report at http://bugreport.apple.com/.

    The greater the number of bug reports, the greater the chance that Apple will finally realize how bad this bug is and fix it.

Leave a Reply

Comments are closed.