Tip: You can get the filename without the extension of a file or multiple files using the GetFileNameWithoutExtension method:
OverloadDefinitions
Single file
1 |
[System.IO.Path]::GetFileNameWithoutExtension('C:\Demo\file01.txt') |
Multiple files
1 |
Get-ChildItem -Path C:\Demo -Filter *.txt | ForEach-Object -Process {[System.IO.Path]::GetFileNameWithoutExtension($_)} |
Pingback: Powershell Tip #108: Bulk rename extensions of files | Powershell Guru
Pingback: Powershell Tip #110: Replace multiple spaces by one comma | Powershell Guru