Skip to content

Instantly share code, notes, and snippets.

@obar1
Created October 24, 2025 09:21
Show Gist options
  • Select an option

  • Save obar1/9bb3ea06a4e5f9181e872915f697fec4 to your computer and use it in GitHub Desktop.

Select an option

Save obar1/9bb3ea06a4e5f9181e872915f697fec4 to your computer and use it in GitHub Desktop.

Revisions

  1. obar1 created this gist Oct 24, 2025.
    22 changes: 22 additions & 0 deletions list_dirs_save_in_md.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Define output file
    $outputFile = "Subfolders.md"

    # Get current directory
    $currentDir = Get-Location

    # Get all subfolders
    $subfolders = Get-ChildItem -Path $currentDir -Directory

    # Start Markdown content
    $markdownContent = "# Subfolders in `$($currentDir)`n`n"

    # Add each subfolder as a bullet point with space replaced by %20
    foreach ($folder in $subfolders) {
    $encodedName = $folder.Name -replace ' ', '%20'
    $markdownContent += "* [here](./$encodedName/readme.md)`n"
    }

    # Save to file
    $markdownContent | Out-File -FilePath $outputFile -Encoding UTF8

    Write-Host "Markdown file saved as $outputFile"