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($_)} |