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?
# the path
$file = 'C:\Temp\MyFolder\mytextfile.fake.ext.txt'
# using regular expression
$file -replace '\.[^.\\/]+$'
# or using System.IO.Path (too verbose but useful to know)
Join-Path ([System.IO.Path]::GetDirectoryName($file)) ([System.IO.Path]::GetFileNameWithoutExtension($file))