Searching for "dir" command with folder indention

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pstein
Posts: 125
Joined: 09 Nov 2011 01:42

Searching for "dir" command with folder indention

#1 Post by pstein » 25 May 2016 04:32

Normally when I execute the "dir" command on Win 7 then users can only

- list all files of (only) the current directory
or
- list the full directory tree where each sub directory having its own section.

What I need is a dir command where all files of a directory tree are listed integrated in ONE section and the corresponding subdirectory level is shown by indention with 2 blanks per hierarchy level.

To give an example: a directory tree of 3 directories with 2 files in each should be listed with a special adjusted "dir" command as follows:

Code: Select all

subdir      <dir>
  subsubdir    <dir>
     25.02.2016   23:18           345.434   file111.txt 
     24.03.2016   21:08           456.477   file112.txt
   15.11.2015   02:28        677.658.011  file11.txt
   25.02.2016   23:18        234.552.435  file12.txt
28.04.2016   12:28                412  file1.txt
31.03.2016   19:44        665.654.411  file2.txt
                       6 File(s) 1.578.667.180 bytes


Mind that subfolders come first and that the sum at the bottom is the sum of ALL files.

How can I achieve this with a DOS script which enhances the "normal" built-in "dir" command?

Peter

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Searching for "dir" command with folder indention

#2 Post by Squashman » 25 May 2016 06:21

Code: Select all

H:\test>tree /f
Folder PATH listing for volume DATA
Volume serial number is D2F3-49FA
H:.
│   mylog.txt

├───foe3
├───foo
│   └───servers
│       └───FS1
│           └───data
│               └───config
│                       test.temp

└───foo2

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Searching for "dir" command with folder indention

#3 Post by Aacini » 25 May 2016 08:03

If you want the output of tree command formatted in a certain way, you may take my MyTree.bat program and modify it.

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Searching for "dir" command with folder indention

#4 Post by foxidrive » 25 May 2016 11:38

Peter, it would help to clarify your task if you show a real directory listing and then show how you would like it modified.

Your example shows two directory names instead of three and doesn't indicate which listing applies to which folders. IE: the indentation doesn't match the files and it's not very clear what you're after.

Someone could take a guess about what you mean, but it's not much fun rewriting code a second time if the guess is wrong.

pstein wrote:To give an example: a directory tree of 3 directories with 2 files in each should be listed with a special adjusted "dir" command as follows:

Code: Select all

subdir      <dir>
  subsubdir    <dir>
     25.02.2016   23:18           345.434   file111.txt 
     24.03.2016   21:08           456.477   file112.txt
   15.11.2015   02:28        677.658.011  file11.txt
   25.02.2016   23:18        234.552.435  file12.txt
28.04.2016   12:28                412  file1.txt
31.03.2016   19:44        665.654.411  file2.txt
                       6 File(s) 1.578.667.180 bytes


Post Reply