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)