Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Renames files from two directories interleaving them in a merged directory. Intended use with a two-camera diybookscanner.
#!/bin/bash
IFS="$(echo -e "\n\r")"
BASE="page"
EXTN="JPG"
DEST_DIR="MergedPages"
I=0
ls ./EvenPages/*.$EXTN |
sort |
while read FNAME
do
#convert -rotate 270 "$FNAME" "$FNAME"
DIGITS=$(printf "%04d" $I)
mv "$FNAME" "${DEST_DIR}/${BASE}${DIGITS}.${EXTN}"
I=$(( I + 2 ))
done
I=1
ls ./OddPages/*.$EXTN |
sort |
while read FNAME
do
#convert -rotate 90 "$FNAME" "$FNAME"
DIGITS=$(printf "%04d" $I)
mv "$FNAME" "${DEST_DIR}/${BASE}${DIGITS}.${EXTN}"
I=$(( I + 2 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment