Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Last active December 20, 2015 09:59
Show Gist options
  • Save snipsnipsnip/6112434 to your computer and use it in GitHub Desktop.
Save snipsnipsnip/6112434 to your computer and use it in GitHub Desktop.
pushd-shortcut.bat: ショートカットの飛び先を読み取ってそこまでpushdする
@if exist "%~f1" @(
echo pushd "%~f1"
pushd "%~f1"
) else @for %%i in (%1.lnk) do @(
for /f %%n in ('perl -x "%~f0" %%~$path:i') do @(
echo pushd %%n
pushd %%n
)
)
@exit /b
#!perl
use strict;
use Win32::Shortcut;
use File::Basename qw/dirname/;
exit 1 unless @ARGV && -e $ARGV[0];
my $link = Win32::Shortcut->new();
$link->Load($ARGV[0]);
print -d $link->{'Path'} ? $link->{'Path'} : dirname $link->{'Path'};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment