This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

run batch w/o .bat?


In my $HOME I have a bin directory that I populate with symbolic links to all
*.bat files in my $PATH.  Here is a bash script to populate it...

enjoy.
Lynn

-----------------------
#!/bin/bash

Origpath=$PWD
for Testpath in ${PATH//:/' '} ; do

if [ -d $Testpath ] ; then
    cd $Testpath
    Basepath="$(pwd | cygpath --unix -f -)"
    Batfiles=$( ls -1 *.bat *.bash  2> /dev/null )

    for Batfile in $Batfiles; do
        Realfile="${Basepath}/${Batfile}"
        Linkname=${Batfile##/*/}
        Linkname=${Linkname%%.*}

        Linkname=~/bin/$Linkname
        if [ -e $Linkname ] ; then
            echo Warning... link to $Realfile exists > /dev/stderr
        else
            echo linking $Realfile --- $Linkname
            ##rm -f $Linkfile
            ln -s "$Realfile" "$Linkname"
        fi
    done
fi

done

echo "removing link for ~/bin/pgp"
rm ~/bin/pgp

cd $OrigPath

exit 0

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]