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
|
if echo $link | grep -E '^[http|\/]' >/dev/null; then
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
if [ $(find . -name "$link"".md" 2>/dev/null | wc -l) -gt 0 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -24,14 +36,15 @@ searchfile() {
|
||||||
else
|
else
|
||||||
echo "In $1:"
|
echo "In $1:"
|
||||||
echo $link
|
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
|
if [ $(echo -n "$FILES" | wc -c) -lt 1 ]; then
|
||||||
echo "Could not find"
|
echo "Could not find"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$FILES" | cat --number
|
echo "$FILES" | cat --number
|
||||||
read PICK
|
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')')
|
REPLACE=$(escape '('$link')')
|
||||||
REPLACEWITH=$(escapeReplace "$FILE")
|
REPLACEWITH=$(escapeReplace "$FILE")
|
||||||
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
||||||
|
@ -40,7 +53,8 @@ searchfile() {
|
||||||
fi
|
fi
|
||||||
echo "In $1:"
|
echo "In $1:"
|
||||||
echo $link
|
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
|
if [ $(echo -n "$FILES" | wc -c) -lt 1 ]; then
|
||||||
echo "Could not find"
|
echo "Could not find"
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue