none
FOR /F Creates Wrong List of Absolute Paths. Please Advise RRS feed

  • Question

  • Using the line below

    for /f "delims=" %D in ('dir /a:d /b c:\Users\') do @echo %~fD

    When executed from: c:\Users\  the absolute paths (to directories below it)  ARE CORRECT! (see top list in figure below)

    Now, CD to subdirectory  “Utils” and execute the line again, i’m getting WRONG paths! (see bottom list)

    Qn: Is there a way to get correct paths to directories C:\Users “sees” when executed from sub-directory : C:\Users\Utils ?

    Is there “a solution” rather than “a work around’ That is to say, how to get absolute paths to remote “tree” of directories

    Saturday, September 23, 2017 11:25 PM

Answers

  • Oops!! Not so fast..

    Dear \_(ツ)_/ my apology

    Unfortunately, just realized that running the line you suggested (with modifications for getting the full path) produced the following below. The question is re opened.

    Thanks, Uxy

    Sorry.  Its a Martian name.  I still miss my old home.

    That is a not what "f' was designed for so it will not give you what you want.  Use PowerShell.  CMD is being removed from Windows.  No point in learning is now.


    \_(ツ)_/

    • Marked as answer by Uxy Monday, September 25, 2017 7:16 PM
    Sunday, September 24, 2017 9:34 AM

All replies

  • Try this:

    for /f "delims=" %d in ('dir  /b c:\Users\') do @echo %d


    \_(ツ)_/


    • Edited by jrv Sunday, September 24, 2017 12:09 AM
    • Marked as answer by Uxy Sunday, September 24, 2017 4:17 AM
    • Unmarked as answer by Uxy Sunday, September 24, 2017 5:50 AM
    Sunday, September 24, 2017 12:03 AM
  • Many thanks \_(ツ)_/ (Japanese name?) for Fast and Clean answer

    Uxy

    Indeed replacing %d with %~fd works

    Sunday, September 24, 2017 4:17 AM
  • Oops!! Not so fast..

    Dear \_(ツ)_/ my apology

    Unfortunately, just realized that running the line you suggested (with modifications for getting the full path) produced the following below. The question is re opened.

    Thanks, Uxy

    Sunday, September 24, 2017 6:09 AM
  • Oops!! Not so fast..

    Dear \_(ツ)_/ my apology

    Unfortunately, just realized that running the line you suggested (with modifications for getting the full path) produced the following below. The question is re opened.

    Thanks, Uxy

    Sorry.  Its a Martian name.  I still miss my old home.

    That is a not what "f' was designed for so it will not give you what you want.  Use PowerShell.  CMD is being removed from Windows.  No point in learning is now.


    \_(ツ)_/

    • Marked as answer by Uxy Monday, September 25, 2017 7:16 PM
    Sunday, September 24, 2017 9:34 AM
  • Haaa, sad day..

    May be a there is good soul (a Venusian?)  that is able to enlighten me on my lost & forgotten path

    The focus should be on the problem, namely: is there a simple method to find, “remotely” absolutie paths to a sub-tree of directory

     The following line does the job (the Qn. title is rather miss-leading..) .

    for /d %D in (C:\Users\*) do @echo %~fD

    Many thanks, Uxy



    • Edited by Uxy Monday, September 25, 2017 9:38 PM Style + answer found
    Sunday, September 24, 2017 5:49 PM