Created
December 21, 2017 18:08
-
-
Save mayjs/00d744fd82ff2aa89052356d14d9ed79 to your computer and use it in GitHub Desktop.
Recursively convert all recently changed *.xoj files in a directory to pdf (requires a patched version of xournal)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script converts all xournal xoj files in subdirectories of the current working directories to pdf files | |
# It also checks if the file was recently changed. | |
# To do this, it compares modification timestamps of these files with the modification timestamp of the script files itself. | |
# The script will also update its own modification timestamp afterwards. | |
SCRIPT="$(realpath "$0")" | |
# Converts a single xoj file to pdf. | |
function convertXoj { | |
XOJ="$(realpath "$1")" | |
PDF="$(echo "$XOJ" | sed 's/xoj$/pdf/g')" | |
# The -A option for xournal does only exist in xournal installations with a certain patch. | |
# Check my github repository (https://github.com/mayjs/xournal_patched) for a version with this patch applied. | |
xournal -A "$PDF" "$XOJ" | |
} | |
export -f convertXoj | |
# Convert every xoj file that has been changed after this file. | |
find . -type f -name "*.xoj" -newer "$SCRIPT" -exec bash -c 'convertXoj {}' \; | |
# Update the modification time of this file using touch. | |
touch $SCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment