Quick Guide: How to Show DOS 8.3 File Names

Written by

in

To find and show DOS names (also known as 8.3 short filenames or SFNs) using PowerShell, you cannot rely on native properties of standard Get-ChildItem output, because native .NET objects do not expose them. Instead, you must use Windows COM objects or fallback to legacy command wrappers. Use the FileSystemObject COM Object

The most reliable programmatic method in PowerShell uses the Scripting.FileSystemObject COM engine. This object exposes a ShortName property for the name and a ShortPath property for the entire DOS-compliant file path. Show the short name for a single file: powershell

\(fso = New-Object -ComObject Scripting.FileSystemObject \)fso.GetFile(“C:\Program Files\Internet Explorer\iexplore.exe”).ShortName Use code with caution. Show the short path for a single folder: powershell

\(fso = New-Object -ComObject Scripting.FileSystemObject \)fso.GetFolder(“C:\Program Files”).ShortPath Use code with caution. Map an Entire Directory

To see the long names and short names side-by-side for an entire directory, pipe your items to ForEach-Object and build a custom object: powershell

\(fso = New-Object -ComObject Scripting.FileSystemObject Get-ChildItem "C:\Program Files" | ForEach-Object { [PSCustomObject]@{ LongName = \).Name ShortName = if ($.PSIsContainer) { \(fso.GetFolder(\).FullName).ShortName } else { \(fso.GetFile(\).FullName).ShortName } } } Use code with caution. Quick Wrap of Legacy Command

If you only need a quick visual readout in your terminal window without capturing objects, wrap the traditional command prompt’s dir /x function. The /x flag forces Windows to print the 8.3 generation layout side-by-side with the long names: powershell cmd.exe /c dir /x “C:\Program Files” Use code with caution. Troubleshooting: Missing Short Names

If you notice that a long file name returns its exact long string instead of a tilde format (like PROGRA~1), it means 8.3 name creation is disabled on that storage drive.

You can check your system’s global or volume status with this administrative command: powershell fsutil 8dot3name query C: Use code with caution.

If you want to automate this or configure your storage system, tell me if you need to:

Enable 8.3 compliance across an entire active volume using administrative commands.

Bulk-convert a list of long file paths inside a script to populate a legacy environment variable. Use PowerShell to display Short File and Folder Names

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *