JSI Tip 5217. How can I right-click a folder in Windows Exporer to Print Directory Listing?

You can navigate through the complexity of the Windows Explorer GUI to configure additional functionality when you right-click a folder,  or you can use the Registry Editor and, optionally, batch files.

I have scripted PDL.bat to add a Print Directory Listing command to the context menu that is displayed when you right-click a folder.

PDL.bat contains:

@echo off
@echo @echo off>"%WinDir%\PrtDir.bat"
@echo dir ""%%1"" /-p /o:gn ^> "%temp%\DirList.log">>"%WinDir%\PrtDir.bat"
@echo start /w /min notepad /p "%temp%\DirList.log">>"%WinDir%\PrtDir.bat"
@echo del /q "%temp%\DirList.log">>"%WinDir%\PrtDir.bat"
@echo exit>>"%WinDir%\PrtDir.bat"
@echo REGEDIT4>"%temp%\pdl.reg"
@echo \[HKEY_CLASSES_ROOT\Directory\shell\]>>"%temp%\pdl.reg"
@echo @="none">>"%temp%\pdl.reg"
@echo \[HKEY_CLASSES_ROOT\Directory\shell\Print_Directory_Listing\]>>"%temp%\pdl.reg"
@echo @="Print Directory Listing">>"%temp%\pdl.reg"
@echo \[HKEY_CLASSES_ROOT\Directory\shell\Print_Directory_Listing\command\]>>"%temp%\pdl.reg"
call :windows %SystemRoot%\pdl.reg
@echo @="%drv%\%fld%\PrtDir.bat \"%%1\"">>"%temp%\pdl.reg"
regedit /s "%temp%\pdl.reg"
del /q "%temp%\pdl.reg"
goto :EOF
set drv=%~d1
set fld=%~p1

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.