Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: Launch Windows Explorer from Windows DOS prompt

by larryl (Scribe)
on Apr 14, 2006 at 21:14 UTC ( #543439=note: print w/replies, xml ) Need Help??

in reply to Re: Launch Windows Explorer from Windows DOS prompt
in thread Launch Windows Explorer from Windows DOS prompt

I combined jimbojones' original script with the ideas from davidrw, and then added a command-line option so you could specify a path. So for example you can set up desktop shortcuts to open an explorer window pointing to things like "C:\Apache\conf".

I had to change the -d test in the sort specification from
   -d $b <=> -d $a
   (-d $b ? 1 : 0) <=> (-d $a ? 1 : 0)
because I was getting errors messages about invalid numeric comparison...

use warnings; use strict; use Cwd; use File::Spec (); use IO::Dir; my $path = shift || cwd(); $path = File::Spec->canonpath($path); if (-d $path) { chdir $path or die "Can't chdir to \"$path\"\n"; my $dir_handle = IO::Dir->new($path) or die "Can't open \"$path\"\n"; my @items = sort { (-d $b ? 1 : 0) <=> (-d $a ? 1 : 0) || $a cmp $ +b } grep { ! /^[.][.]?$/ } $dir_handle->read; undef $dir_handle; $path = File::Spec->catfile($path, $items[0] || '.'); } elsif (! -f $path) { die "Can't find \"$path\"\n"; } exec 'explorer.exe /e,/select,' . $path; # launch Explorer exit;


Replies are listed 'Best First'.
Re^3: Launch Windows Explorer from Windows DOS prompt
by davidrw (Prior) on Apr 14, 2006 at 21:57 UTC
    nice ..

    yeah, i guess that would generate warnings since -X returns 1 or undef ..could save a few characters with -d $b || 0 <=> -d $a || 0 Another alternative would be to do a Schwartzian Transform (especially if there might be a large number of directories).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://543439]
[karlgoethebier]: choroba: another chapter of "Learning English At The Monastry"?
[shmem]: Corion, well then... next issue, sequence number not a shared resource :P
[Discipulus]: shmem i'm searching it.. but failing i was sure was in Re: Let's Make PerlMonks Great Again! -- suggestions and dreams
erix recommends Vanished Kingdoms
[Corion]: shmem: Yeah, something like that. Not that that would be a solved issue. Simply process all events that come in from a single interface sequentially. Ah well.
[Discipulus]: their

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2017-05-23 08:29 GMT
Find Nodes?
    Voting Booth?