PowerShell Rename won't work. Cannot rename the specified target, because it represent a path or device name

68 views Asked by At

I think is my code that has a problem. I'm working with RSS that saves as .XML; The RSS file is Live and I want to change the .XML file when the RSS changes using File check after the RSS has been get already.

RSS Feed: ["https://alerts.weather.gov/cap/wwaatmget.php?x=FLC083&y=0"]

Save as: C:\RSS_Name.XML
$path = C:\RSS_Name.XML

#Using Parse to get title inside the .XML
$Data = Get-Content C:\RSS_Name.XML
[xml]$Data = Get-Content C:\RSS_Name.XML
$InputFileNAme = $path
$OutputFileName = $Data.feed.entry.title
Rename-Item -Path $InputFileNAme -Force -NewName "New_Name$($OutputFileName).xml"
$file = "New_Name$($OutputFileName).xml"
Write-Host $file "Answers New_Name$($OutputFileName).xml"

Error: Rename-Item: Cannot rename specified target, because represent a path or device name.

I want the Title inside the .xml to be my save file name. And it works but as soon as the title changes from the rss wont allow me to rename

I tried different fixes regarding Rename-Item from stackoverflow but didn't work.

0

There are 0 answers