more features and fixes
This commit is contained in:
parent
2d5b274036
commit
d78200f593
|
@ -12,6 +12,18 @@ searchfile() {
|
|||
if echo $link | grep -E '^[http|\/]' >/dev/null; then
|
||||
continue
|
||||
fi
|
||||
if echo $link | grep -E '^\.\/' >/dev/null; then
|
||||
NEWLINK=$(echo $link | sed 's/^\.\///')
|
||||
echo "In $1:"
|
||||
echo $link
|
||||
echo $NEWLINK | cat --number
|
||||
read PICK
|
||||
if [ $PICK -eq 1 ]; then
|
||||
REPLACE=$(escape '('$link')')
|
||||
REPLACEWITH=$(escapeReplace "$NEWLINK")
|
||||
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
||||
fi
|
||||
fi
|
||||
if [ $(find . -name "$link"".md" 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
continue
|
||||
fi
|
||||
|
@ -24,14 +36,15 @@ searchfile() {
|
|||
else
|
||||
echo "In $1:"
|
||||
echo $link
|
||||
FILES=$(find . -iname "*$(basename "$link")*")
|
||||
SEARCH='*'$(basename "$link" | sed 's/[-_ ]/*/g')'*'
|
||||
FILES=$(find . -iname "$SEARCH")
|
||||
if [ $(echo -n "$FILES" | wc -c) -lt 1 ]; then
|
||||
echo "Could not find"
|
||||
continue
|
||||
fi
|
||||
echo "$FILES" | cat --number
|
||||
read PICK
|
||||
FILE=$(echo "$FILES" | head -n $PICK | tail -n 1)
|
||||
FILE=$(echo "$FILES" | head -n $PICK | tail -n 1 | sed 's/^\.\///')
|
||||
REPLACE=$(escape '('$link')')
|
||||
REPLACEWITH=$(escapeReplace "$FILE")
|
||||
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
||||
|
@ -40,7 +53,8 @@ searchfile() {
|
|||
fi
|
||||
echo "In $1:"
|
||||
echo $link
|
||||
FILES=$(find . -iname "*$(basename "$link")*")
|
||||
SEARCH='*'$(basename "$link" | sed 's/[-_ ]/*/g')'*'
|
||||
FILES=$(find . -iname "$SEARCH")
|
||||
if [ $(echo -n "$FILES" | wc -c) -lt 1 ]; then
|
||||
echo "Could not find"
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue