Private/Remove-specFileExtension.ps1
Function Remove-specFileExtension { <# .SYNOPSIS Removes the file extension from a file name if it exists .DESCRIPTION Removes the file extension from a file name if it exists .PARAMETER FileName The name of the file to remove the file extension from .EXAMPLE Remove-specFileExtension -FileName "SPECLauncher.ps1" Returns: "SPECLauncher" Removes the file extension from the file name "SPECLauncher.ps1" .EXAMPLE Remove-specFileExtension -FileName "SPECLauncher" Returns: "SPECLauncher" Returns the file name "SPECLauncher" as it does not have a file extension .NOTES File : Remove-specFileExtension.ps1 Author : owen.heaume Version : 1.0 #> [cmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$FileName ) # remove the file extension of any type if it exists and retun the filename without the file extension if ($FileName -like "*.*") { $FileName = $FileName.Substring(0, $FileName.LastIndexOf('.')) } return $FileName } |