Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Rename-Item does not exist

$
0
0

Still working on photos and moving them when i have time. 

We have thousands of Photos that are a format used by ID card printers. When the extension is changed to .jpg they work fine with our other systems.

I wrote this small piece that on the first run as separate commands was fine. when i joined the code to a script it failed. after the failure i retried my steps and all works except for the the rename portion...WHICH DID originally. 

The files clearly copy over and manually i can rename them and change the extension and the open in any picture viewer.

But Powershell will not change or can not even see the files. 

 

Rename-Item : Cannot rename because item at '88001518.9' does not exist.

At line:12 char:3

+         Rename-Item $File $FileNew

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException

    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

 

$Source="\\PC-002766\C$\Test\test\"
$Dest="\\LT-003077\C$\Test\test\Import\"


Remove-Item$Dest\*-Recurse

RoboCopy $source$dest/np /NFL /NDL /NJH /NJS

$Proj_Files=Get-ChildItem$Dest | Where-Object {$_.Extension-ne".jpg"}
foreach ($FileIn$Proj_Files) {
$FileNew=$File.name+".jpg"
Rename-Item$File$FileNew
}


Viewing all articles
Browse latest Browse all 6937

Trending Articles