Search-and-go in Windows CMD

1

I know that for file search on Windows CMD one can use the following command:

dir /S /P "PATH/FILENAME"

Is there an easy way to go straight to the result directory. For example, the requested file is found in:

C:\Program Files................\myProgram\Readme.txt

How to quickly go to that directory via CMD (any commands)? Or one has to simply mark and copy/paste the path on the next prompt?

LionBass

Posted 2014-07-21T11:56:18.097

Reputation: 11

Answers

0

I know this is not the exact solution for your question, but you can always open a command prompt at a specified location by navigating to the desired location using windows explorer and then by pressing shift + right click and clicking "Open command window here".

If you already knew this, please disregard this.

Hope it helps.

sirius_helper

Posted 2014-07-21T11:56:18.097

Reputation: 281

0

No built-in (DOS) way that I know of, but if you have some common "UNIX" tools available, this will work:

dir /s /p Portal.sln | grep "^ Directory of" | sed -e "s/^ Directory of //" | open.pl

where open.pl is:

#!perl

use strict;
use warnings;

$| = 1;

if (scalar(@ARGV) == 0) {
  print "Please enter the file or folder path you would like to open:\n";
  my $path = <STDIN>;
  chomp $path;
  ConvertAndOpen($path);
}
else {
  foreach my $arg (@ARGV) {
    ConvertAndOpen($arg);
  }
}

sub ConvertAndOpen {
  my $path = shift || die "No path specified";
  $path =~ s/\//\\/g;
  `start "open" "$path"`;
}

jimtut

Posted 2014-07-21T11:56:18.097

Reputation: 832

Thanks for the suggestion. I see there is no simple solution. – LionBass – 2014-08-01T12:15:58.323