When I run the following command:
Rename-Item some\long\path\fileName.txt some\long\path\newName.txt
I receive the following error message:
Cannot rename the specified target, because it represents a path or device name.
I've tried wrapping the paths in quotes and that doesn't succeed either.
For the second argument, just use the new name not the full path. That is, do this:
Rename-Item some\long\path\fileName.txt newName.txt
From the docs, it says of -NewName<String>
Enter only a name, not a path and name. If you enter a path that is different from the path that is specified in the Path parameter, Rename-Item generates an error.
For me the issue was different
The file name was the issue:
I have tried to put the following file name:
Old_2016-02-17T13:52:28_Stage1.txt
But only After changing it to:
Old_17022016_0154_Stage1.txt
it worked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With