aboutsummaryrefslogtreecommitdiff
path: root/copy-annotations-from-kobo
diff options
context:
space:
mode:
Diffstat (limited to 'copy-annotations-from-kobo')
-rwxr-xr-xcopy-annotations-from-kobo16
1 files changed, 15 insertions, 1 deletions
diff --git a/copy-annotations-from-kobo b/copy-annotations-from-kobo
index 271328f..19c894c 100755
--- a/copy-annotations-from-kobo
+++ b/copy-annotations-from-kobo
@@ -14,7 +14,8 @@ PATTERN="$1"
# https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client#38160
function silentSsh {
local connectionString="$1"
- local commands="$2"
+ shift
+ local commands="$*"
if [ -z "$commands" ]; then
commands=`cat`
fi
@@ -34,6 +35,19 @@ show --search "$PATTERN" | while read item; do
extension="$(echo $item | sed -e "s|$basename.||")"
sdr="$basename.sdr"
+ # Check if remote file exists
+ silentSsh $REMOTE <<EOT
+ test -e "$REMOTE_BASE/$sdr/metadata.$extension.lua"
+EOT
+
+ # Skip if remote file does not exist
+ if [ "$?" != "0" ]; then
+ echo "Skipping $item as it's not available at $REMOTE..."
+ continue
+ fi
+
+ echo "Processing $item..."
+
# Make sure that the annotation file exists
mkdir -p "$BASEFOLDER/$sdr"
touch "$BASEFOLDER/$sdr/metadata.$extension.lua"