So there's a little confusion here, which isn't a big deal because, well, this stuff is confusing at first.
Long story short, you only need one set of "quotes" around variables and you do not want to "escape the quotes" (which is what it is called when you put \
in front of it).
So what you want is this:
/usr/local/bin/ocrmypdf "$KMVAR_path" "$KMVAR_path" -l nld --rotate-pages --deskew
Ok, so that gets us that far.
However, now I need to ask a question, because I'm not very familiar with ocrmypdf
but you have "$KMVAR_path"
listed there twice. Is the intention that you want to use the same filename for input as for output? That is, if you give it a file /Users/myname/Documents/form.pdf
you want to OCR it and save it back to /Users/myname/Documents/form.pdf
?
Most programs can't do that. You'd usually need to save it to a different file and then rename it to the original name at the end.
Also, from a brief look at the documentation for the ocrmypdf
tool, it appears that you need to use:
- the
ocrmypdf
program itself
- then any options like
-l nld --rotate-pages --deskew
- Then the name of the input file
- Then the name of output file.
So something like this, assuming that you want to take the name of the file from whatever Keyboard Maestro has selected:
/usr/local/bin/ocrmypdf --language nld --rotate-pages --deskew "$KMVAR_path" "$HOME/Desktop/newfile-ocr.pdf"
You'll note that I used --language
instead of -l
this is just a personal preference that I have developed over many years. When I am writing a script, I want it to be as clear as possible to "Future Me" what I was doing, and I never want to trust that "Future Me" will remember what I was trying to do, or how any of these programs work. So I don't trust "Future Me" to remember what the short option (-l
) means, which is why I use --language
because it will help "Future Me" by being more clear.
(When I am just entering commands at the command line I will use the short options, but when I am writing a script I always prefer to use the longer ones.)
So… is what I have close to what you are trying to do?
Now you'll probably have noticed immediately that there's a problem with my script. Every file that is OCR'd will be saved to "$HOME/Desktop/newfile-ocr.pdf"
which will only work if you do one file at a time. But we'll deal with that later, once I'm clear on what you're trying to do.