How to Use Windows DIR Command to Show Only Folder Names with Link Information

Abstract: Filter Windows DIR output to list only folders and identify symbolic links using PowerShell or CMD parsing.

Created: 2026-09-04 by
The Windows DIR command does not have a built-in switch to display only folder names with link information. To achieve this, you must combine the /AD flag for directories with output redirection and parsing tools like FINDSTR or PowerShell. This approach filters the standard directory listing to isolate specific items, providing the precise control needed for batch scripting and automation tasks without relying on non-existent flags.

Understanding DIR Output Limitations

The DIR command is a powerful utility for listing files and directories, but it lacks a dedicated parameter for showing "only" folders in a custom format that includes link details by default. A common misconception involves looking for switches like /L or others that might imply lowercase or link-specific output. These do not exist. The DIR command outputs a verbose list including attributes, size, date, and name. To get just folder names, you must filter this output.

Furthermore, "link information" in Windows typically refers to symbolic links or junction points. Standard DIR output marks these with an L attribute in the first column of the output. However, extracting this specific data requires parsing the text output, as there is no single command-line argument that returns only folder names alongside their symlink status in a clean, machine-readable format.

Filtering Directories Using Command Prompt

If your goal is simply to list folder names without file entries, the most effective method uses the /AD (Attributes: Directory) switch combined with /B (Bare format). The /B switch removes extra information like headers and summary counts, leaving just the names.

dir /ad /b

This command lists all subdirectories in the current path. If you need to include hidden folders, add the /AH switch. While this does not explicitly show "link information," it provides the clean list of folders often required for subsequent processing. For more complex filtering, such as excluding system folders, you can pipe the output to FINDSTR.

dir /ad /b | findstr /v /i "system"

This technique allows you to refine the list further. It is important to note that this method does not distinguish between regular folders and symbolic links. To identify links, you must look at the attributes in the full DIR output or use PowerShell.

Using PowerShell for Advanced Link Detection

PowerShell offers superior capabilities for identifying symbolic links and junctions compared to the traditional Command Prompt. The Get-ChildItem cmdlet (aliased as gci or dir) can inspect the Attributes property of each item. Symbolic links have the ReparsePoint attribute set.

Get-ChildItem -Directory | Where-Object { $_.Attributes -match 'ReparsePoint' } | Select-Object Name

This script retrieves all directories and filters them to show only those that are reparse points (symbolic links or junctions). You can modify the Where-Object clause to exclude certain types of links or to include regular directories as well. This method provides the "link information" aspect that the native DIR command cannot easily provide in a filtered view.

For a broader overview that includes both regular folders and links, you can list all directories and check their type:

Get-ChildItem -Directory | Select-Object Name, @{Name="Type";Expression={if($_.Attributes -match 'ReparsePoint'){'Link'}else{'Folder'}}}

This creates a custom object with the folder name and its type, making it easy to identify which directories are actual links. This is far more reliable than trying to parse the text-based output of DIR, which can be locale-dependent and inconsistent.

Parsing DIR Output for Attributes

If you must stick to Command Prompt, you can parse the raw DIR output to find lines containing both directory indicators and link markers. The full DIR output starts with a line indicating if it is a volume or directory. Each file/directory line starts with attributes like D for directory, A for archive, etc. A symbolic link directory might appear as L or include D depending on the version and context, but usually, symlinks are marked with L in the attribute column.

dir /a:d | findstr /r "^....L"

This regex attempts to match lines where the 5th character (attributes) indicates a link. However, this is fragile because the spacing and formatting of DIR can vary based on screen width and language settings. It is generally recommended to avoid this method for production scripts due to its instability.

Integrating with Batch Processes

When automating tasks, you often need to process these folder names. You can combine the FOR loop with the filtering techniques mentioned above. For example, to iterate over all symbolic link directories using PowerShell within a batch file:

powershell -Command "Get-ChildItem -Directory | Where-Object { $_.Attributes -match 'ReparsePoint' } | ForEach-Object { Write-Output $_.FullName }"

This command executes PowerShell from within a .bat file, captures the output, and prints the full paths of all symbolic link directories. This approach leverages the strength of PowerShell for identification while maintaining compatibility with legacy batch environments.

For more advanced text manipulation, consider combining these results with other tools. If you need to extract specific metadata or descriptions from these folders, you might look into related techniques for handling file metadata. See How to Get File Description Field from File Metadata Using Command Line for details on retrieving additional properties.

Best Practices for Directory Listing

  • Use Bare Format: Always use /B when scripting to avoid parsing headers and footers.
  • Handle Spaces: When iterating through results, ensure your loops handle paths with spaces correctly by using quotes.
  • Prefer PowerShell: For any task involving attribute inspection or complex filtering, PowerShell is significantly more robust than CMD.
  • Test Locally: Always test your commands in a safe environment before applying them to critical systems, as modifying or deleting linked folders can break shortcuts or dependencies.

Frequently Asked Questions

Does DIR have a switch to show only symbolic links?

No, the DIR command does not have a specific switch to list only symbolic links. You must use the /A attribute filter combined with text parsing or switch to PowerShell for accurate identification of reparse points.

Why is my DIR output different on different computers?

The formatting of DIR output depends on the code page, language settings, and window width. This variability makes parsing DIR output unreliable for scripts. Using /B minimizes differences, but PowerShell is still preferred for consistency across different locales.

Can I use DIR to delete all empty folders?

While DIR can list empty folders, it cannot delete them directly. You would need to pipe the output to a RMDIR command using a FOR loop, but caution is advised to avoid deleting non-empty directories accidentally.

What is the difference between a junction and a symbolic link?

Both are reparse points, but junctions are limited to local volumes and are essentially hard links to directories, while symbolic links can span across volumes and point to files or directories. PowerShell's Get-ChildItem treats both similarly under the ReparsePoint attribute.

How do I hide system folders from DIR output?

Use the /A-D switch to exclude directories, or /A:-D to include only non-directories. To exclude system folders specifically, you may need to filter out names starting with $ or use FINDSTR to remove known system directory names from the list.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More