JSI Tip 3558. How can I open Notepad with a list of all files system objects on a drive?

To accomplish the subject task, you could open a CMD prompt, switch (CD) to the root of the drive, and type:

dir *.* /s /b > filename.txt & notepad filename.txt

NOTE: Filename.txt will be created in the root of the drive.

If you wish to sort the folder name and file names, and control the placement of the output file, type:

DriveObj ReportFile Drive1: \[Drive2 Drive3 Driven\]

where: ReportFile is the full path to the output file. Example: "%UserProfile%\My Documents\Cobjects.txt" or c:\folder\Cobjects.txt.

Drive1: is the drive letter of the first drive you want included.

Drivex: are optional additional drive letters to include.

Example: DriveObj D:\reports\DriveObj.txt C: D: E: F: G: H: I:

DriveObj.bat contains:

@echo off
if \{1\} EQU \{\} goto syntax
if \{2\} EQU \{\} goto syntax
set report=%1
set wrk=%TEMP%\%~nx1
set wrk=%wrk:\\=\%
if exist %report% del /f /q %report%
if exist %wrk% del /f /q %wrk%
if \{%1\} EQU \{\} goto end
set drive=%1
set drive=%drive:\=%
set drive=%drive:"=%
set drive=%drive::=%
set drive=%drive%:
cd /d %drive%
dir *.* /s /b >> %wrk%
goto loop
@echo *************************************************
@echo DriveObj ReportFile Drive1: \[Drive2 Drive3 Driven\]
@echo *************************************************
goto :EOF
sort %wrk% /O %report%
del /q %wrk%
start notepad %report%

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.