Windows: how to pipe cd and where command
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
In the Windows console
- By
where
command, I'll find a file within%PATH
e.g:where cmd
->C:WindowsSystem32cmd.exe
- 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
New contributor
add a comment |Â
up vote
2
down vote
favorite
In the Windows console
- By
where
command, I'll find a file within%PATH
e.g:where cmd
->C:WindowsSystem32cmd.exe
- 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
New contributor
Potentially similar: superuser.com/questions/1261588/â¦... Probably not though but just in case
â Pimp Juice IT
2 hours ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
In the Windows console
- By
where
command, I'll find a file within%PATH
e.g:where cmd
->C:WindowsSystem32cmd.exe
- 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
New contributor
In the Windows console
- By
where
command, I'll find a file within%PATH
e.g:where cmd
->C:WindowsSystem32cmd.exe
- 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
windows command-line
New contributor
New contributor
edited 3 hours ago
DavidPostillâ¦
100k25213249
100k25213249
New contributor
asked 3 hours ago
ê°Âì¤Â모
112
112
New contributor
New contributor
Potentially similar: superuser.com/questions/1261588/â¦... Probably not though but just in case
â Pimp Juice IT
2 hours ago
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered 3 hours ago
DavidPostillâ¦
100k25213249
100k25213249
add a comment |Â
add a comment |Â
ê°Âì¤Â모 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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Potentially similar: superuser.com/questions/1261588/â¦... Probably not though but just in case
â Pimp Juice IT
2 hours ago