Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename fails because it represents a path or device name

Tags:

powershell

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.

like image 355
Shaun Luttin Avatar asked Apr 14 '15 19:04

Shaun Luttin


2 Answers

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.

like image 67
Shaun Luttin Avatar answered Sep 22 '22 16:09

Shaun Luttin


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

like image 42
dsaydon Avatar answered Sep 23 '22 16:09

dsaydon