anki-decks/fromtext.sh

22 lines
493 B
Bash
Executable file

#!/bin/sh
SEP='\t'
COLUMNS='4 5'
main() {
while read -r line; do
filename=
i=0
for c in $COLUMNS; do
f="$(echo "$line" | awk -F$SEP "{print \$$c}")"
[ -z "$f" ] && continue
if [ "$filename" = '' ]; then
filename="$(echo "$f" | tr '[:upper:]' '[:lower:]' | sed -e 's/ /-/g' -e 's/[^a-z0-9-]//g')"
fi
echo "$f" > "$filename.$i.md"
i=$((i+1))
done
done
}
main "$@"