Often I'll find it helpful to give a LLM context of my file structure for coding projects, so I co-wrote this script to only grab the relevant files and output them in a nicely formatted tree.
As you can see, it ignores common directories in a VS code (Nuxt and Vue) project and in a Pycharm (Python) project. It also only grabs files with approved extensions.
function Print-Tree {
param (
[string]$Path,
[string]$Indent = ""
)
$excluded = @('.nuxt', 'node_modules', '.venv', 'venv', '.idea', '__pycache__')
$extensions = @(".py", ".txt", ".md", ".ini", ".ts", ".json", ".vue", ".yaml", ".env")
Get-ChildItem -Path $Path | Where-Object { $_.Name -notin $excluded } | ForEach-Object {
if ($_.PSIsContainer) {
Write-Output "$Indent|-- $($_.Name)"
Print-Tree -Path $_.FullName -Indent "$Indent| "
} else { # Use this line for all extensions
# } elseif ($extensions -contains $_.Extension) { # Use this line to only include whitelisted extensions
Write-Output "$Indent|-- $($_.Name)"
}
}
}
# Call the function with the initial path
Print-Tree -Path "C:\Users\david\source\davehague-site"
It's been really helpful to have this script to give the LLM extra context about my project.