Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

Jun
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
 
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
 
> 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
 
> 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
 
pdir /(fpn) "c:\level1\*.doc" > output.txt

...works for me, although the absence of quote marks may be an issue.
 
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
[email protected]
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
 
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.
 
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
 
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
 
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
 
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
 
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
 
Back
Top
[FOX] Ultimate Translator
Translate