[bug[ Check for already existing files and folder before rename.

Fixes #2560 

Actually, just do `if (newName.isNotEmpty && resource.parent != null)` above.