#!/bin/bash ############################################################################### # # # This script replaces XML codes with HUGO shortcodes and then outputs # # the result as a new file named "index.md" in the same folder as # # the source file. # # # # Drag and drop a markdown file onto one of the .desktop files in this folder # # index.md will appear next to the original file that you dragged. # # The original file will remain unchanged. # # # ############################################################################### # Check for input file if [ ! -f "$1" ]; then echo No file was dropped onto this Desktop file. exit 1 fi if [[ "$1" == *"index.md"* ]]; then echo You dropped the index.md on here file by accident! exit 1 fi input="$1" # Create a temp file temp=$(mktemp) cp "$input" "$temp" # Replace text # sed -i 's/oldtext/newtext/g' "$temp" # sed -i 's/<\/codeFile>/">}}{{<\/codeFile>}}/g' "$temp" # sed -i 's/<\/imgSource>/>}}{{<\/imgSource>}}/g' "$temp" # sed -i 's/<\/markdownFile>/>}}{{<\/markdownFile>}}/g' "$temp" # sed -i 's/<\/textFile>/>}}{{<\/textFile>}}/g' "$temp" # sed -i 's/<\/date>/{{}}{{<\/date>}}/g' "$temp" # sed -i 's/