PowerShell Output Filenames of a Specific Extension to a Text File


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?


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

Answered By – Willz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published