2

I should mention I'm new to command lines.

I want to rename files using the mv command in the Terminal. I type:

mv oldFileName.pdf newFileName.pdf

Afterwards, I use the ls command to check whether things work as expected. The presented list shows me what I expected: The old file name does not appear, but the new one does.

However, when I use Finder and open the folder in which I renamed the file, it shows me two things: The old file name and the new file name. The file with the new file name is fine, but double-clicking the file with the old file name, I get the message

"oldFileName.pdf" can't be found.

When I use Finder to delete oldFileName.pdf, then both the damaged / "missing" oldFileName.pdf and the file newFileName.pdf are moved to Trash (even though I only right-clicked oldFileName.pdf to delete it).

It looks to me as if there was something wrong. What's the problem? Should I not use mv to rename files?

As a test, I checked what happens when I use the mv command on folders. I created an empty folder named oldFolderName,

mkdir oldFolderName

and renamed it,

mv oldFolderName newFolderName

Again, the ls command shows me newFolderName but no oldFolderName. However, in Finder, I now see two folders with the same name newFolderName, which is a bit different to what happened when I copied .pdf files, but which is still an unexpected behaviour. Again, when I delete one of the two folders, both go into Trash.

What's wrong? What's the right way to rename files and folders via the command line?

Edit: I'm using OS X Yosemite, 10.10.2. I just made an observation: The problem I described arises in folders that are within my Dropbox. The problem doesn't seem to arise in folders outside my Dropbox. Could there be an issue with using the mv command in the Dropbox?

Edit 2: The problem only seems to arise in Dropbox folders that I share with other people, but not in folders which only I have access to (and the NSA).

Edit 3: Similar problems arise when I use the rm command in such folders. The deleted files are still shown in Finder, and trying to delete them in Finder results in the error message

The operation can't be completed because one or more required items can't be found. (Error code -43)

  • 1
    You are doing it right (at least it works ok for me here, since years), it seems to be rather Finder who is confused. Is this on your main drive (HFS formatted) or on a mounted one? – nohillside Mar 11 '15 at 10:16
  • It's on the main hard drive (format: Mac OS Extended (Journaled) of a relatively new iMac. I have no other drives connected to this computer. – Corsin Pfister Mar 11 '15 at 10:18
  • Which is your OS? Click the apple icon in the top left corner of the screen and select "About This Mac". – jaume Mar 11 '15 at 10:20
  • It's OS X Yosemite, 10.10.2. I just made an observation: The problem I described arises in folders that are within my Dropbox. The problem doesn't seem to arise in folders outside my Dropbox. Could there be an issue with using the mv command in the Dropbox? – Corsin Pfister Mar 11 '15 at 10:22
  • It might just be a refresh issue, how much time did you give Dropbox to resync after the changes? – Tetsujin Mar 11 '15 at 10:25
-1

command+opt/alt +esc to force quit / relaunch Finder fixes the out-of-sync problem.
Not a great solution, but it does work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .