Quickly Changing File Extensions

by Jun 9, 2011

If you want to quickly exchange a file extension to create a "bak" backup version or generate a new file name for output, you should use the ChangeExtension() method:

$oldpath = 'c:\test\datei.csv'
$newpath = [System.IO.Path]::ChangeExtension($oldpath, '.xls')
$oldpath
$newpath

 

Twitter This Tip!
ReTweet this Tip!