1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Support' started by dragonfly, Jun 4, 2008.

  1. dragonfly

    Joined:
    Jun 4, 2008
    Messages:
    5
    Likes Received:
    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
     
    #1
  2. vpdura

    Joined:
    Jun 3, 2008
    Messages:
    26
    Likes Received:
    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?:


    Try *dir /s /f c:\level1\*.doc
     
    #2
  3. Jay Sage

    Joined:
    Jun 2, 2008
    Messages:
    239
    Likes Received:
    1
    > 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
     
    #3
  4. Jay Sage

    Joined:
    Jun 2, 2008
    Messages:
    239
    Likes Received:
    1
    > 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
     
    #4
  5. dragonfly

    Joined:
    Jun 4, 2008
    Messages:
    5
    Likes Received:
    0
    Thank you vpdura and Jay for the prompt responses.

    I'll now dive deeper into the command library.
     
    #5
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    2,767
    Likes Received:
    18
    pdir /(fpn) "c:\level1\*.doc" > output.txt

    ...works for me, although the absence of quote marks may be an issue.
     
    #6
  7. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    904
    Likes Received:
    4
    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:

    Try *dir /s /f c:\level1\*.doc
     
    #7
  8. dragonfly

    Joined:
    Jun 4, 2008
    Messages:
    5
    Likes Received:
    0
    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.
     
    #8
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    2,767
    Likes Received:
    18
    You're right; I completely forgot the /S.
     
    #9
  10. logic

    Joined:
    May 30, 2008
    Messages:
    42
    Likes Received:
    0
    From: samintz
    Sent: Wednesday, June 04, 2008 9:58 AM
    Subject: 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'

    ..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
     
    #10
  11. logic

    Joined:
    May 30, 2008
    Messages:
    42
    Likes Received:
    0
    From: samintz
    Sent: Wednesday, June 04, 2008 9:58 AM
    Subject: 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'

    ..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
     
    #11
  12. dragonfly

    Joined:
    Jun 4, 2008
    Messages:
    5
    Likes Received:
    0
    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
     
    #12
  13. logic

    Joined:
    May 30, 2008
    Messages:
    42
    Likes Received:
    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?


    That's exactly how :-)

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

    Jonathan Gilbert_
    \\\ / / / \ |_) |_/
    \\\/ \/ \__/ | \ | \
    Software Systems
     
    #13
  14. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,531
    Likes Received:
    4
    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
     
    #14

Share This Page