I created a PowerShell module called PowerTree because I couldn't exclude certain folders using the standard Tree cmdlet. PowerTree mimics the classical representation of a directory tree while adding several unique features, such as excluding specific folders like node_modules, showing file details like size and date, filtering by file type or size, and options for sorting among others. Additionally, users can save the results directly to a text file. I'm looking for feedback on potential bugs, feature requests, usability, and any coding best practices I should adopt. Here are some examples of how to use it:
- To see a basic tree view, just run: `Ptree`
- For a view that includes file sizes sorted in descending order: `Ptree -DisplaySize -SortBySize -Descending`
- To filter by extensions or exclude directories: `Ptree -IncludeExtensions ps1,md -ExcludeDirectories bin,node_modules`
- For a more advanced view with minimum and maximum file sizes: `Ptree -s -desc -sort size -fsmi 100kb -fsma 1mb`
You can find the module on GitHub and the PowerShell Gallery. I'd greatly appreciate your insights!
5 Answers
Your project looks interesting! I haven't tested it, but consider a few improvements:
- For auto-importing the module, list functions explicitly in your psd1 instead of using export-modulemember.
- Instead of using backticks for line continuations, try splatting; it might clean up your code.
- Regarding the internal quiet functionality, using write-verbose is preferable.
- You might want to simplify string interpolation with the format operator. Also, some return statements in your functions seem unnecessary and could be removed.
Cool tool! Do you plan to add permission reporting for the directories? Knowing the access permissions could be really beneficial.
One concern is that you may hit the path length limitation using Get-ChildItem. Even though Windows 11 supports longer paths, I've encountered issues with it before. You might want to check out `[system.io.directory]::EnumerateFiles()` instead, as it’s more efficient for large directories.
Your tool is shaping up nicely! If you could include visualizations similar to WinDirStat, that would really enhance its appeal!
Looks promising! Just a heads up, you might want to add functionality that provides information about non-inherited NTFS permissions. Also, tracking character and path lengths separately would be quite useful!
Related Questions
Online Hash Generator - String to Hash Converter
Convert CSV To HTML Table
Convert Json To Xml
Bitrate Converter
JavaScript Multi-line String Builder
GUID Generator