You have the order of the names in the rename call reversed. The old name comes first, then new name second.
In reply to Re^3: Swapping Files by BrowserUk in thread Swapping Files by deadpickle