Disclaimer
This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

List files in a directory by file type and size (powershell)

My boss asked me to find out how many mp3 files that were hanging out on our NAS device, we’re getting a little close on storage capacity.

Below is what I came up with. The script searches the Z: (change to whatever drive letter you want to search) and finds all mp3 (*.mp3) files and outputs the results (filename, size and directory location) to the listfiles.csv file.

get-childitem z:\ -filter *.mp3 -recurse |  
select-object Name, Length, directory | Sort-object Directory | 
export-csv c:\scripts\listfiles.csv -notype

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.