Fixes bug when renaming a directory into a subdirectory.
Merge pull request #1704 from michaeljbishop/rename-bug

Fixes bug when renaming a directory into a subdirectory.