can PDIR list full filepaths of docs in a nested folder?

Jun 4, 2008
5
0
I have just started using Take Command in command line mode (in a batch file). In short, a newbie.

I'm sure this must be straight forward in Take Command but I did search for "filepath" and found nothing in the forum.

I need to list all MS Word .doc files in a nested folder (several levels of nesting).

I need to pipe the full filepaths of all files into a text file (to create a batch processing file)

e.g. look for all *.doc files in c:\level1 folder

c:\level1\file1.doc
c:\level1\level2\file2.doc
c:\level1\level2\file3.doc

I've tried PDIR command but can't see how to list the above nested full filepaths.

What PDIR command line arguments should I use?

Also, in command line usage, can the output from TCC commands be "piped" to a text file like this ...

PDIR /(sp) > output.txt
 
Jun 3, 2008
27
0
On Wed, 04 Jun 2008 07:57:58 -0500, dragonfly <>
wrote Re [Support-t-123] can PDIR list full filepaths of docs in a
nested folder?:


>e.g. look for all *.doc files in c:\level1 folder
>
>c:\level1\file1.doc
>c:\level1\level2\file2.doc
>c:\level1\level2\file3.doc

Try *dir /s /f c:\level1\*.doc
 
Jun 2, 2008
373
2
Newton, MA
> I need to list all MS Word .doc files in a nested
> folder (several levels of nesting). I need to pipe
> the full filepaths of all files into a text file (to
> create a batch processing file)

How about

FFIND /S *.doc > file

or

DIR /S /B /1 *.doc > file

-- Jay
 
Jun 2, 2008
373
2
Newton, MA
> I need to list all MS Word .doc files in a nested
> folder (several levels of nesting). I need to pipe
> the full filepaths of all files into a text file (to
> create a batch processing file)

How about

FFIND /S *.doc > file

or

DIR /S /B /1 *.doc > file

-- Jay
 

samintz

Scott Mintz
May 20, 2008
1,489
15
Solon, OH, USA
Both the /F and the /B switch essentially accomplish the same thing when
used with /S. /B normally does not contain path info and will color code
the output when *not* used with /S. Otherwise, when /S is used full path
info is output and no color coding.

Another important feature is that /H (hide . and .. directories) is
implied with /B but it is *not* with /F. In your case, since you are
just looking for .DOC files, either switch will accomplish your goals.

There are *no* built-in ways to get relative paths however. When used
with /S, both /F and /B will contain full path information.

You can do something like this to get relative paths:
for /f %f in ('dir /sb *.doc') do echo %@substr[%f,%@len[%_cwds]]

-Scott




vpdura <>
06/04/2008 09:22 AM
Please respond to



To
Samintz@ra.rockwell.com
cc

Subject
RE: [Support-t-123] can PDIR list full filepaths of docs in a nested
folder?






On Wed, 04 Jun 2008 07:57:58 -0500, dragonfly <>
wrote Re [Support-t-123] can PDIR list full filepaths of docs in a
nested folder?:


Quote:

>e.g. look for all *.doc files in c:\level1 folder
>
>c:\level1\file1.doc
>c:\level1\level2\file2.doc
>c:\level1\level2\file3.doc
Try *dir /s /f c:\level1\*.doc
 
Jun 4, 2008
5
0
pdir /(fpn) "c:\level1\*.doc" > output.txt

...works for me, although the absence of quote marks may be an issue.

thanks but that only works at the first level of the folder .. i.e. *.doc files in lower hierarchical levels are not listed in a long list of files with long paths.
 
May 30, 2008
42
0
From: samintz
Sent: Wednesday, June 04, 2008 9:58 AM
Subject: RE: can PDIR list full filepaths of docs in a nested folder?

>
> There are *no* built-in ways to get relative paths however. When used
> with /S, both /F and /B will contain full path information.

If one is not averse to external tools here and there, the UNIX 'find'
utility, which I'm sure has been ported to Win32, can give relative paths.
It can also apply a wildcard to the filenames -- something like:

find . -name '*.doc'

..might achieve the listing the O.P. wants but using relative paths.

One needs to be careful not to confuse this with the FIND.EXE that comes
with Windows, which is essentially GREP without the RE part.

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems
 
May 30, 2008
42
0
From: samintz
Sent: Wednesday, June 04, 2008 9:58 AM
Subject: RE: can PDIR list full filepaths of docs in a nested folder?

>
> There are *no* built-in ways to get relative paths however. When used
> with /S, both /F and /B will contain full path information.

If one is not averse to external tools here and there, the UNIX 'find'
utility, which I'm sure has been ported to Win32, can give relative paths.
It can also apply a wildcard to the filenames -- something like:

find . -name '*.doc'

..might achieve the listing the O.P. wants but using relative paths.

One needs to be careful not to confuse this with the FIND.EXE that comes
with Windows, which is essentially GREP without the RE part.

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems
 
Jun 4, 2008
5
0
If one is not averse to external tools here and there, the UNIX 'find'
utility, which I'm sure has been ported to Win32, can give relative paths.
It can also apply a wildcard to the filenames -- something like:

find . -name '*.doc'

I've just checked that with Cygwin on windows and it seems to work .. not sure though how file paths/names can be piped to a text file .. > filelist.txt
 
May 30, 2008
42
0
From: dragonfly
Sent: Wednesday, June 04, 2008 2:55 PM
Subject: RE: Re: can PDIR list full filepaths of docs in a nested folder?


> > If one is not averse to external tools here and there, the UNIX 'find'
> > utility, which I'm sure has been ported to Win32, can give relative
> > paths. It can also apply a wildcard to the filenames -- something like:
> >
> > find . -name '*.doc'
>
> I've just checked that with Cygwin on windows and it seems to work .. not
> sure though how file paths/names can be piped to a text file
> .. > filelist.txt

That's exactly how :-)

find . -name '*.doc' > filelist.txt

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems
 
May 20, 2008
3,515
4
Elkridge, MD, USA
dragonfly wrote:
| ---Quote---
| If one is not averse to external tools here and there, the UNIX 'find'
| utility, which I'm sure has been ported to Win32, can give relative
| paths.
| It can also apply a wildcard to the filenames -- something like:
|
| find . -name '*.doc'
| ---End Quote---
| I've just checked that with Cygwin on windows and it seems to work ..
| not sure though how file paths/names can be piped to a text file .. >
| filelist.txt

You cannot PIPE to a file. You can pipe only to a process. You can REDIRECT
to a file. Once the terminology issue is clarified, you can find how to
redirect STDOUT only, STDERR only, or both to a file in HELP topic
redirection.htm. Note that you can redirect STDOUT and STDERR to different
files at the same time. You can also PIPE both STDOUT and STDERR,
interleaved as they would be on the screen, to another process, but the
syntax does not support piping STDERR only to a process, regardless of what
is the destination of STDOUT.

To display paths relative to the current working directory in PDIR I utilize
a function:

function relfile=`%@replace[%_cwds,,%@full[%&]]`

If I want files, but not subdirectories, in the current directory and its
subdirectories listed, I use the command

*pdir/ne/ou/s/a:-d/(@relfile[*]) *.doc

The latter can be redirected easily:

*pdir/ne/ou/s/a:-d/(@relfile[*]) *.doc > docfiles.lst

Alternately, the comand Z can executed on each file by piping:

*pdir/ne/ou/s/a:-d/(@relfile[*]) *.doc | for %x in (@con) Z %x

which last form skips the explicit intermediate file.

If files or subdirectories with names requiring quoting may occur, the last
one could be changed to:

*pdir/ne/ou/s/a:-d/(@relfile[*]) *.doc | for %x in (@con) Z "%x"

Note that this method quotes all files.
--
HTH, Steve
 
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 PDir format question... Support 3
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
FreezerBurnt ANSI Prompt messes up list output. Support 39
T Is there a way to maintain the position in the environment list, while debugging? Support 10
Alpengreis List command: text truncated in find box (german) Support 9
L LIST's pop-up search loses focus in a Windows Terminal window Support 15
A List windows with titles matching given pattern? Support 2
C How to make list of drive contents when shutdown PC / Everything.exe Support 7
D _USBS list misses flash drives that @USB recognizes. Support 7

Similar threads