PDir format question...

May 24, 2010
Northlake, Il
I am trying to do something where I have done similar things many times in the past re. the PDir command. Specifically, I am trying to call a function from within a function, and this time around I can't get it to work and I don't know what I am doing wrong. So as a slightly made-up example that perfectly illustrates the problem I am having:
[Z:\Compression Stuff]Function WW=`%1`

[Z:\Compression Stuff]PDir *.txt /Ou /(WW[@FileSize[*]/@Lines[*]] fpn)
WW[49926/481] Z:\Compression Stuff\Analyzed Z-Drive Compression Statistics For Comp
ressed Files.txt
WW[103111/1002] Z:\Compression Stuff\Analyzed Z-Drive Compression Statistics.txt
WW[109110/1002] Z:\Compression Stuff\Analyzed Z-Drive Compression StatisticsIII.txt
WW[52797/480] Z:\Compression Stuff\Compressed Z-Drive Files .txt
WW[95177/1455] Z:\Compression Stuff\Compression Report Stage 1.txt
WW[95177/1455] Z:\Compression Stuff\Compression Report Stage 2.txt
WW[2069/56] Z:\Compression Stuff\ExtractDateTime .btm Subroutine.txt
WW[180/0] Z:\Compression Stuff\Raw PDir Compression Report.txt
WW[56311/520] Z:\Compression Stuff\Uncompressable Z-Drive Files.txt
which works as one would expect but does nothing useful.

So modifying it a bit to come closer to what I am actually trying to accomplish:
[Z:\Compression Stuff]PDir *.txt /Ou /(@WW[%%@FileSize[*]/%%@Lines[*]] fpn)
TCC: (Sys) The filename, directory name, or volume label syntax is incorrect.
From everything I know/have done/remember, this should work (no percent sign on the outer function, duplicating the percent signs on the inner functions).

What am I missing/doing wrong?

- Dan
May 24, 2010
Northlake, Il
Important update to the above. It is strictly related to the "@Lines" function; "/(@WW[%%@FileSize[*]/%%@FileSize[*]]" is silly, but works perfectly (doing nothing useful).


Staff member
May 14, 2008
It won't work in either case -- you cannot repeat nested '*' substitution in a single function. PDIR will do the first substitution embedded in the @WW argument and pass the remainder as-is.

(It only *appeared* to work with the "@WW[%%@FileSize[*]/%%@FileSize[*]" syntax because @FILESIZE will accept wildcard arguments and @LINES will not.)
May 24, 2010
Northlake, Il
Thank you for the explanation, Rexx. That's why I was able to get it to work when I replaced the @WW function definition by function that @ExecStr'd a .btm file that did a few other related things that I also wanted to do while it was at it. And from experimenting a little bit it seems that a function "AvgLineLength" defined as `%@Eval[%@FileSize[%1]/%@If[%@FileSize[%1] == 0,1,%@Lin
es[%1]],=1.1]` almost works but because both the "true" and the "false" side of an "@If" are always evaluated and there are, in fact, 0-length files the .btm file with an actual "Iff" statement is the only way I could accomplish that, anyway. I do think that you should make a note that multiple asterisks in the arguments to a single function that is being invoked by PDir is not suppored in the documentation, however, since I really wouldn't call it "expected" behavior (although it's not that unexpected, either!).

As far as the WW function goes, it really doesn't matter but I no longer remember what its original purpose was. No real surprise there, I think...
Similar threads
Thread starter Title Forum Replies Date
Phileosophos PDIR to list filenames without extensions? Support 2
vefatica PDIR and streams Support 1
vefatica PDIR with fixed-width unqualified filename? Support 2
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
thedave pdir /s Support 2
Emilio III pdir /f switch Support 1
D pdir ignores pm Support 2
WadeHatler pdir broken in 19.1 for directories with spaces Support 1
M WAD PDir not working correctly... Support 5
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
mfarah More on pdir's options: /(fq) Support 5
mfarah How to? Getting pdir to display relative paths. Support 2
S PDIR and @LABEL questions Support 4
M How to? PDir on multiple wildcard patterns... Support 2
A pdir function usage Support 3
T How to? dir/pdir - 2nd level down only Support 7
JohnQSmith PDIR and descriptions Support 21
G WAD PDIR @IF bug, @WORD bug Support 8
S WAD PDIR: files with percent sign % in name cause not listing other files in directory Support 9
S WAD PDIR ignores exclusion ranges Support 1
M How to? "PDir" not working the way the I _thought _ the documentation said it does… Support 8
S WAD /Sn mishandled in DIR and PDIR, possibly elsewhere Support 15
S Fixed GPF in PDIR Support 3
S PDIR issue Support 1
M PDir causing Take Command/TCC to crash... Support 6
M A "PDir" issue... Support 16
M A simple question related to the "dir" (and "pdir") commands... Support 5
J pdir /b1 issue Support 20
M Missing PDir option... Support 5
J Maybe Not So Hard Pdir Question Support 1
S PDIR fails in 12.10.55 Support 3
J V12 PDIR failure Support 1
S PDIR command causes GPF Support 5
D pdir inconsistency Support 4
S PDIR has trouble processing filenames with embedded percent sign Support 3
P PDIR woes Support 0
gschizas pdir crashes horribly in one specific folder Support 5
S PDIR question Support 2
S pdir /(fq) not working Support 5
R Colored directory listing bug with pdir. Support 1
nickles Bias in PDIR Support 5
F pdir problem Support 3
D can PDIR list full filepaths of docs in a nested folder? Support 13
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
T Date format date different from cmd Support 7
vefatica @TIMER's format ... Support 2
T Elapsed time format in prompt changed in TCC 25 Support 10
Joe Caverly DATE format 4 Support 7
M Fixed Set "VAR=VAL" format causes problems Support 12
fpefpe touch - date format Support 2

Similar threads