Neat listing

#1
I'd like to produce the following output from a directory (_ = space, [] = <>)

D:\temp\down\check\vb41\app32_________________________[DIR]
D:\temp\down\check\vb41\data__________________________[DIR]
D:\temp\down\check\vb41\source________________________[DIR]
D:\temp\down\check\vb41\Portable-VirtualBox.exe__33.345.345
Total: 3 directories, 33.345.345 bytes


How would I do that?

Could that be done recursively (just giving me the grand total)?

(Where the heck does the _ _ come from?)
 
#2
nickles wrote:
| I'd like to produce the following output from a directory:
|
| D:\temp\down\check\vb41\app32
|
| D:\temp\down\check\vb41\data
|
| D:\temp\down\check\vb41\source
|
| D:\temp\down\check\vb41\Portable-VirtualBox.exe 33.345.345
| Total: 3 directories, 33.345.345 bytes
|
| How would I do that?
|
| Could that be done recursively (just giving me the grand total)?

To list only directory names:
*dir/b/ogen/a-d/p/nej/s

If you want to exclude links (junctions and symlinks):
*dir/b/ogen/a-d-j/p/nej/s

Look at the /U2 option to get the totals; probably filtering it through TAIL
or @EXECSTR to get only the one desired line.
--
HTH, Steve
 
#4
@Steve

Thanks for the answer, but please mind the exact format of what I hope to obtain (preferably w/o using any third party tool like perl):

I'd like to get a listing like this:

Code:
[FONT=Courier New]D:\temp\down\ubuntu                              [DIR] 
D:\temp\down\oki_b6250                          60.522 
D:\temp\down\cream.txt                           1.199 
D:\temp\down\tux.txt                             1.222 
D:\temp\down\yongwei.txt                         1.203 
D:\temp\down\ubuntu\$CONFIG                      [DIR] 
D:\temp\down\ubuntu\$CONFIG\boottime.kmap.gz     4.744 
D:\temp\down\ubuntu\$CONFIG\bookmarks.html      10.565 
D:\temp\down\ubuntu\$CONFIG\prefs.js             4.898 
[the_grand_total_for_this_and_all_contained_directories]
[/FONT]
Btw. Using /u[1|2] in DIR just gives me the one summary line, nothing more.

p.s. I alread tried lots of options for DIR and PDIR and neither the necessary switches are there (as in the case of the grand total summary line), nor the justification is working ok (as in the case of PDIR with field length prefixes)...

nickles
 
#5
nickles wrote:
| @Steve
|
| Thanks for the answer, but please mind the exact format of what I
| hope to obtain (preferably w/o using any third party tool like perl):
|
| I'd like to get a listing like this:
|
|
| Code:
| D:\temp\down\ubuntu [DIR]
| D:\temp\down\oki_b6250 60.522
| D:\temp\down\cream.txt 1.199
| D:\temp\down\tux.txt 1.222
| D:\temp\down\yongwei.txt 1.203
| D:\temp\down\ubuntu\$CONFIG [DIR]
| D:\temp\down\ubuntu\$CONFIG\boottime.kmap.gz 4.744
| D:\temp\down\ubuntu\$CONFIG\bookmarks.html 10.565
| D:\temp\down\ubuntu\$CONFIG\prefs.js 4.898
| [the_grand_total_for_this_and_all_contained_directories]
| Btw. Using /u[1|2] in DIR just gives me the one summary line, nothing
| more.
|
| p.s. I alread tried lots of options for DIR and PDIR and neither the
| necessary switches are there (as in the case of the grand total
| summary line), nor the justification is working ok (as in the case of
| PDIR with field length prefixes)...

PDIR does the job for files:
pdir /(-40fpn zc) /s
However, it displays the string "<DIR>" unjusttified, 2 characters left of
where you want it. I had already suggested (for a future version) the
ability of that string to be justified.
Another gotcha: To match CMD.EXE, even in PDIR, which has no matching CMD
command, Rex always displays the widest possible field.

I see two alternatives:
1/ Postprocess ach line, using @REPLACE to move the DIR-indicator, and cut
the size field to your desired width.
2/ Use a function to create the size/DIR field within PDIR, along the lines
below:
- use @IF to determine entry type
- if DIR, return a fixed string of the right width
- if file, use @FILESIZE, combined with @FORMATN, to build the exact format
desired.

To generate the single summary line, I would use the DIR/U2, and extract the
one line of interest with @EXECSTR[2,dir/u2/s] (untested!) or with TAIL, and
append.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,501
45
Albuquerque, NM
prospero.unm.edu
#6
@Steve

Thanks for the answer, but please mind the exact format of what I hope to obtain (preferably w/o using any third party tool like perl):

I'd like to get a listing like this:

Code:
[FONT=Courier New]D:\temp\down\ubuntu                              [DIR] 
D:\temp\down\oki_b6250                          60.522 
D:\temp\down\cream.txt                           1.199 
D:\temp\down\tux.txt                             1.222 
D:\temp\down\yongwei.txt                         1.203 
D:\temp\down\ubuntu\$CONFIG                      [DIR] 
D:\temp\down\ubuntu\$CONFIG\boottime.kmap.gz     4.744 
D:\temp\down\ubuntu\$CONFIG\bookmarks.html      10.565 
D:\temp\down\ubuntu\$CONFIG\prefs.js             4.898 
[the_grand_total_for_this_and_all_contained_directories]
[/FONT]
I think you're looking for something like this:

Code:
function xsize=`%@format[13,%@if[isdir %1,[DIR],%@filesize[%1,bc]]]`

alias xdir=pdir /(-30fn @xsize
[*]) /m
 
#7
[email protected], Steve

Thanks for the help of both of you!

I finally came up with this version:

Code:
function xsize = `%@format[13,%@filesize[%1,bc]]`
alias lrs = `pdir %DIRCMD% /d /s /(-85fpn @xsize
[*]) & color bright blue on black & echo This directory: %@format[83,%@filesize[%_cwd,bc]] & dir /k /s /u2 | fgrep allo & color white on black`
Interestingly, the formatting in PDIR does not work correctly when using "sp" instead of "fpn" like in:

Code:
pdir /d /s /(-85sp zp)
which describes my initial attempt to handle the problem.
So, the "fpn" and the "function" approach helped a lot!
 

samintz

Scott Mintz
May 20, 2008
1,241
11
Solon, OH, USA
#8
I think you need to use -30fpn in the XDIR
alias though. Otherwise, none of the paths show up.
You might consider putting the sizes
first and the names in the second column. Otherwise on paths longer
than 30 chars the formatting gets messed up.
Also, by including the /m switch, you
get totals for each directory instead of one big total at the end.

So here is my variant:

Code:
function xsize=`%@format[13,%@if[isdir %1,[DIR],%@filesize[%1,bc]]]`
alias xdir=`pdir /(@xsize[*] fpn) %$
& dir /u2 /k %$`
-Scott

Charles Dye <> wrote on
07/21/2011 09:59:48 AM:


> From: Charles Dye <>
> To: [email protected]
> Date: 07/21/2011 09:59 AM
> Subject: RE: [Support-t-2985] Re: Neat listing
>
> Quote:
>
> Originally Posted by nickles [image removed]
> @Steve
>
> Thanks for the answer, but please mind the exact format of what I

> hope to obtain (preferably w/o using any third party tool like perl):
>
> I'd like to get a listing like this:

> Code:
> D:\temp\down\ubuntu
[DIR]


> D:\temp\down\oki_b6250
60.522

> D:\temp\down\cream.txt
1.199

> D:\temp\down\tux.txt
1.222

> D:\temp\down\yongwei.txt
1.203

> D:\temp\down\ubuntu\$CONFIG
[DIR]

> D:\temp\down\ubuntu\$CONFIG\boottime.kmap.gz 4.744
> D:\temp\down\ubuntu\$CONFIG\bookmarks.html 10.565

> D:\temp\down\ubuntu\$CONFIG\prefs.js
4.898

> [the_grand_total_for_this_and_all_contained_directories]

>
> I think you're looking for something like this:

> Code:
> function xsize=`%@format[13,%@if[isdir %1,[DIR],%@filesize[%1,bc]]]`
>
> alias xdir=pdir /(-30fn @xsize[*]) /m
>
>
 
#9
nickles:
Beware! If DIRCMD in your alias specifies files or directories to be
cataloged, instead of just additional options, your alias - while it may
work perfectly in your current build - does not conform to TCC grammar, and
might fail in the future. Proper grammar requires entities to be cataloged
after all options are enumerated. OTOH, if it is a COMMAND.COM / CMD.EXE
leftover, containing only options, it is perfectly fine.
--
Steve