Home > Software design >  PowerShell Output Filenames of a Specific Extension to a Text File
PowerShell Output Filenames of a Specific Extension to a Text File

Time:09-19

Currently, I'm using the following command to output filenames to a text file:

( Get-ChildItem -File ).BaseName | Out-File "Track List.txt" -Encoding utf8

How can I limit the filenames to a specific extension, e.g., .mp3?

CodePudding user response:

The -Filter paramater accepts wildecards - ? for any single character, and * for zero or more matches

( Get-ChildItem -File -Filter *.mp3).BaseName | Out-File "Track List.txt" -Encoding utf8

See the Powershell documentaiton on -Filter and wildcards for more information [wildcards]:

  • Related