Rename a File or Directory in PowerShell
Problem
You want to rename a file or directory.
Solution
To rename an item in a provider, use the RenameItem cmdlet: PS > RenameItem example.txt example2.txt
Discussion
The RenameItem cmdlet changes the name of an item. While that may seem like pointing out the obvious, a common mistake is:
PS >RenameItem c:\temp\example.txt c:\temp\example2.txt RenameItem : Cannot rename because the target specified is not a path. At line:1 char:12
+ RenameItem <<<< c:\temp\example.txt c:\temp\example2.txt
- Read more about Rename a File or Directory in PowerShell
- Log in or register to post comments