I understand that using the
moveFileTo() function is the way to rename a file, like using
mv in the shell to rename a file, but my question is, what is a decent algorithm to obtain the “destination” file path?
Let me explain,
I want to change the name of a file in a given folder, but I want it to keep the exact same extension as before.
I want to change:
The extension shouldn’t matter, it should always be the same after as it was before. How can I go about this?
I attempted this, but it seems super long-winded and for some reason, some assignments are not working:
CustomFile fullPath = customListBoxOnePtr->getHighlightedFile(); CustomFile parentDirectory = fullPath.getParentDirectory(); String extension = fullPath.getFileExtension(); fullPath = parentDirectory; // This assignment doesn't work String newPath = fullPath.getFullPathName(); newPath += "/New File Name"; newPath += extension; fullPath = newPath // This assignment doesn't work
I’m not sure how to add on to a file path without assigning it to a string and manipulating that, so any suggestions would be greatly appreciated. I feel like this shouldn’t be as difficult as I’m making it.