Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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]:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading