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

two trees

Discussion in 'T&T - Miscellaneous' started by Roedy, Nov 9, 2011.

  1. Roedy

    Roedy

    Messages:
    94
    I often want to do operations on two directory trees of files.

    I might check for a file to see if it exists in one tree but not the other. doing something to transform a file in one tree to a corresponding slot in the other with a different extension, find out which tree has the newer of each file etc.

    GLOBAL seems to be only applicable to a single tree.

    FOR /r %i is just the file name. It does not give you the depth you are so you can find the corresponding spot in some other tree.

    What other tools are there? If none, maybe you could invent something like GLOBAL that used two trees.
  2. Steve Fabian

    Steve Fabian

    Messages:
    3,531
    From: Roedy
    |...
    | FOR /r %i is just the file name. It does not give you the depth you
    | are so you can find the corresponding spot in some other tree.

    In fact, %i is the full path in that FOR. What you can do is

    %@replace[root1,root2,%i] to get the corresponding filespec in the alternate tree. I do that often!
    --
    HTH, Steve
  3. samintz

    samintz Scott Mintz

    Messages:
    869
    I have found that the behavior of FOR and DO differ in regard to paths.
    But my experience with FOR is exactly the opposite of what you are
    describing.

    This command yields full paths and file names:
    Code:
    for /r %f in (*) do echo "%f"
    
    Whereas this command yields just file names:
    Code:
    do f in /a:-d /s * (echo "%f")
    
    But you can "fix" that by:
    Code:
    do f in /a:-d /s * (echo "%_cwds%%f")
    
    -Scott



    I often want to do operations on two directory trees of files.

    I might check for a file to see if it exists in one tree but not the
    other. doing something to transform a file in one tree to a corresponding
    slot in the other with a different extension, find out which tree has the
    newer of each file etc.

    GLOBAL seems to be only applicable to a single tree.

    FOR /r %i is just the file name. It does not give you the depth you are so
    you can find the corresponding spot in some other tree.

    What other tools are there? If none, maybe you could invent something like
    GLOBAL that used two trees.

Share This Page