I have an absolute path in a variable in my powershell 2.0 script. I want to strip off the extension but keep the full path and file name. Easiest way to do that?
So
if is a [string] type:
[string]
$file.Substring(0, $file.LastIndexOf('.'))
if is a [system.io.fileinfo] type:
[system.io.fileinfo]
join-path $File.DirectoryName $file.BaseName
or you can cast it:
join-path ([system.io.fileinfo]$File).DirectoryName ([system.io.fileinfo]$file).BaseName