Windows: how to pipe cd and where command

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












In the Windows console



  1. By where command, I'll find a file within %PATH

    e.g: where cmd -> C:WindowsSystem32cmd.exe

  2. With result above, I'll move there

I tried...



  • search in google


  • cd %(...


  • where <F> | cd

I think...




  • where command returns the directory and filename

  • So, is there any command to return just the directory?

  • and, what if it is, how to pipe which cd command

  • or, do I need a some script?









share|improve this question









New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
    – Pimp Juice IT
    2 hours ago















up vote
2
down vote

favorite












In the Windows console



  1. By where command, I'll find a file within %PATH

    e.g: where cmd -> C:WindowsSystem32cmd.exe

  2. With result above, I'll move there

I tried...



  • search in google


  • cd %(...


  • where <F> | cd

I think...




  • where command returns the directory and filename

  • So, is there any command to return just the directory?

  • and, what if it is, how to pipe which cd command

  • or, do I need a some script?









share|improve this question









New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
    – Pimp Juice IT
    2 hours ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











In the Windows console



  1. By where command, I'll find a file within %PATH

    e.g: where cmd -> C:WindowsSystem32cmd.exe

  2. With result above, I'll move there

I tried...



  • search in google


  • cd %(...


  • where <F> | cd

I think...




  • where command returns the directory and filename

  • So, is there any command to return just the directory?

  • and, what if it is, how to pipe which cd command

  • or, do I need a some script?









share|improve this question









New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In the Windows console



  1. By where command, I'll find a file within %PATH

    e.g: where cmd -> C:WindowsSystem32cmd.exe

  2. With result above, I'll move there

I tried...



  • search in google


  • cd %(...


  • where <F> | cd

I think...




  • where command returns the directory and filename

  • So, is there any command to return just the directory?

  • and, what if it is, how to pipe which cd command

  • or, do I need a some script?






windows command-line






share|improve this question









New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









DavidPostill♦

100k25213249




100k25213249






New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









강준모

112




112




New contributor




강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






강준모 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
    – Pimp Juice IT
    2 hours ago

















  • Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
    – Pimp Juice IT
    2 hours ago
















Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
– Pimp Juice IT
2 hours ago





Potentially similar: superuser.com/questions/1261588/…... Probably not though but just in case
– Pimp Juice IT
2 hours ago











1 Answer
1






active

oldest

votes

















up vote
2
down vote













How do I use where to cd to the directory where the command is found?



Use the following batch file (test.cmd):



@echo off
for /f %%i in ('where %1') do (
cd /d %%~dpi
)


Example usage:



test cmd



Further Reading



  • An A-Z Index of the Windows CMD command line | SS64.com

  • Windows CMD Commands (categorized) - Windows CMD - SS64.com

  • CD Change Directory - Windows CMD - SS64.com

  • For - Loop through command output - Windows CMD - SS64.com

  • Parameters / Arguments - Windows CMD - SS64.com





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "3"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    강준모 is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1368564%2fwindows-how-to-pipe-cd-and-where-command%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    How do I use where to cd to the directory where the command is found?



    Use the following batch file (test.cmd):



    @echo off
    for /f %%i in ('where %1') do (
    cd /d %%~dpi
    )


    Example usage:



    test cmd



    Further Reading



    • An A-Z Index of the Windows CMD command line | SS64.com

    • Windows CMD Commands (categorized) - Windows CMD - SS64.com

    • CD Change Directory - Windows CMD - SS64.com

    • For - Loop through command output - Windows CMD - SS64.com

    • Parameters / Arguments - Windows CMD - SS64.com





    share|improve this answer
























      up vote
      2
      down vote













      How do I use where to cd to the directory where the command is found?



      Use the following batch file (test.cmd):



      @echo off
      for /f %%i in ('where %1') do (
      cd /d %%~dpi
      )


      Example usage:



      test cmd



      Further Reading



      • An A-Z Index of the Windows CMD command line | SS64.com

      • Windows CMD Commands (categorized) - Windows CMD - SS64.com

      • CD Change Directory - Windows CMD - SS64.com

      • For - Loop through command output - Windows CMD - SS64.com

      • Parameters / Arguments - Windows CMD - SS64.com





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        How do I use where to cd to the directory where the command is found?



        Use the following batch file (test.cmd):



        @echo off
        for /f %%i in ('where %1') do (
        cd /d %%~dpi
        )


        Example usage:



        test cmd



        Further Reading



        • An A-Z Index of the Windows CMD command line | SS64.com

        • Windows CMD Commands (categorized) - Windows CMD - SS64.com

        • CD Change Directory - Windows CMD - SS64.com

        • For - Loop through command output - Windows CMD - SS64.com

        • Parameters / Arguments - Windows CMD - SS64.com





        share|improve this answer












        How do I use where to cd to the directory where the command is found?



        Use the following batch file (test.cmd):



        @echo off
        for /f %%i in ('where %1') do (
        cd /d %%~dpi
        )


        Example usage:



        test cmd



        Further Reading



        • An A-Z Index of the Windows CMD command line | SS64.com

        • Windows CMD Commands (categorized) - Windows CMD - SS64.com

        • CD Change Directory - Windows CMD - SS64.com

        • For - Loop through command output - Windows CMD - SS64.com

        • Parameters / Arguments - Windows CMD - SS64.com






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 3 hours ago









        DavidPostill♦

        100k25213249




        100k25213249




















            강준모 is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            강준모 is a new contributor. Be nice, and check out our Code of Conduct.












            강준모 is a new contributor. Be nice, and check out our Code of Conduct.











            강준모 is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1368564%2fwindows-how-to-pipe-cd-and-where-command%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?