Merging pdfs with automator I'm scanning my mail and end up with two versions: front &amp; back.

Files are named: scanf 01.pdf &amp; scanb 01.pdf

I'm scanning about 40 pages a day, so it ends up to quite some lists.

Now, with automator, I've done the following:


Get Selected Finder Items # "scanf 01.pdf" &amp; "scanb 01.pdf"
Combine PDF Pages
Move Finder Items # to Desktop
Name Single Item # so that its not a random name, but "Scan.pdf"
Add Date or Time # "Scan 2013-01-07.pdf"
Make Sequential # "Scan 2013-01-07 01.pdf" (is at least the idea)
Label Finder Items # Adds a red label, so I didnt see it yet


Step 6 is not working, as the sequence starts over every time I select two new files. So it says 'name already exists', after that it stops.

Questions:


How can I make step 6 work?
Is there something that automatically merges files, so that Scanf 01.pdf is merged with Scanb 01.pdf and that Scanf 02.pdf is merged with Scanb 02.pdf, and so on. As my current automator setup requires me to select the two files.
I didn't really test this, but you could use a shell script instead.

#!/bin/bash

join="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"
date=$(date '+%Y-%m-%d')
last=$(ls ~/Desktop/$date*.pdf 2&gt; /dev/null | tail -n1 | sed -E 's/.* 0*(.*)\.pdf$/\1/g' || 0)

cd ~/Documents/Scanned/
for f in scanf*.pdf; do
    ((last++))
    output="$HOME/Desktop/$date $(printf %03d $last).pdf"
    python "$join" -o "$output" "$f" "${f/scanf/scanb}"
    osascript -e 'on run {f}
tell app "Finder" to set label index of (posix file f as alias) to 2
end' "$output"
done