to rename a file we use Rename-Item command in powershell the command is very simple
Rename-Item $source $dest -force
But what about changing a folder/directory name? I made mistake to write the same command in case of folder/directory rename and it does not work, shows exception file not found which proves that the command is searching for a file not ready to rename and folder/directory.
After googling for some minutes I found the solution and the command is
Rename-Item -path $destFolder -newName $folderNewName
Example: Rename-Item -path ‘C:\AshrafTest\MyFolder’ -newName ‘MyFolder_New’
By the way the folder should contain some data to be rename. Pretty simple but wasted time to search internet so sharing