Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Even though I'm on Windows, I like to use the command line as much as possible. For example, I like to be able to pop a DOS box from right-clicking on a directory in Windows Explorer (see this registry hack).

The reverse of this is to open Windows Explorer from the command line of the DOS box, and have it set to the current directory of the DOS box. The following script formats the call to Explorer's command line arguments to do that. It attempts to highlight the first file or subdirectory in the directory specified. The only bug I have so far is that if you are in an empty directory, Explorer doesn't open the directory for you.

use warnings; use strict; use Cwd; my $cwd = cwd() ; #-- get the subdirs and files opendir ( DIR, $cwd ) || die "$!: dir $cwd doesn't exist!\n"; my @dirs = grep { -d && $_ ne "." && $_ ne ".." } readdir DIR; rewinddir DIR; my @files = grep { -f } readdir DIR; close DIR; $cwd =~ s{/}{\\}g; if ( @dirs ) { $cwd .= '\\'. shift @dirs; } elsif ( @files ) { $cwd .= '\\' . shift @files; } else { $cwd .= '\\.'; } #-- pop the explorer window exec "explorer.exe /e,/select," . $cwd;
Extract the file to expl.pl in your PATH and invoke with

>expl

In reply to Launch Windows Explorer from Windows DOS prompt by jimbojones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (9)
    As of 2014-08-21 12:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (135 votes), past polls