Reputation: 20004
I need to find a file that has a folder in its path that has a dynamic name that changes as I publish some app. (it has a version # appended to it).
C:\somefolder\application_1.0.5.0\myxmlfile.xml
$FilePath = "C:\somefolder\application*\myxmlfile.xml"
Which works great, but I'm changing xml and need to save it again. Upon saving it it's complaining about an illegal character in the path "*".
[xml] $xml = Get-Content..
$xml.Save($FilePath)
How can I get the path that powershell actually resolved in $FilePath
so that I can pass it to the xml save function?
Upvotes: 2
Views: 1049
Reputation: 15707
the Resolve-Path cmdlet will convert wildcards to a full path. Alternatively you could use something like:
$filepattern = "C:\somefolder\application*\myxmlfile.xml"
$filepath = gci $filepattern | select -First 1 -ExpandProperty FullName
Upvotes: 3
Reputation: 1
PS > $FilePath = 'C:\Window*\win.ini'
PS > Convert-Path $FilePath
C:\Windows\win.ini
Upvotes: 3