Automator and Printing

Hello all,

I was hoping someone could help me with a workflow I have created in Automator.

Basically what I have works, but it's not completely doing what I want it to do.

What I have is a workflow that gets a specific Find item (in this case a folder with multiple PDF files) then prints them all at once instead of opening each document and having to print individually.

What I want it to ALSO do is bring up the printer settings for each document before it prints so I can choose double sided printing and so on.

I know this may not seem like it will save time, but instead of opening 30 documents to print each one, I want it to open once, and ask me once how I would like it to be printed. Right now it's not opening my printer settings, it's just printing as normal. Also if I have different types of documents such as a Word doc, Excel and a PDF I would like to be able to pick different printer settings for each type.

If this is not possible, I'm ok with that... I'm kind of new to Automator

Cheers

Mac OS X (10.6.2)

Posted on Jan 12, 2010 7:27 AM

Reply
9 replies

Jan 12, 2010 9:20 AM in response to Bone_Chaos

I know very little about printing but if you go to http://127.0.0.1:631/help/options.html in your web browser you'll get instructions for controlling CUPS from command line. in particular you can create various +printer instances+ with various option presets (like double-sided printing, layouts etc). you can then filter your documents by extension and feed them to lp with different printer instances specified based on extension using "run shell script" action. also, you might want to ask this in the printing forum.

Jan 12, 2010 10:16 AM in response to Bone_Chaos

Bone_Chaos wrote:
I still don't know how to incorporate that into Automator

that should be easy enough I would think.
first create some printer instances as that page describes for various file extensions like .txt .doc, .pdf etc.
then do something along these lines
1. get selected (or specified) finder items
3. run shell script (with input passed as arguments)
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">


for f in "$@"
do
if [ `basename "$f"`==*.doc ]
then
lpr -P printername/docinstance
elif [ `basename "$f"`==*.pdf ]
then
lpr -P printername/pdfinstance
elif [ `basename "$f"`==*.txt ]
then
lpr -P printername/txtinstance
fi
done</pre>




or you can forget about printer instances altogether and use lpr -o and list all print options right in the shell script action. just use different options indifferent cases.

Jan 12, 2010 11:27 AM in response to V.K.

OK ..
This is what I got and it does not work;

Get Specified Finder Items (Add, Remove)

Run Shell Script
Shell: /bin/bash Pass input: as arguments

for f in "$@"
do
if [ `basename "$f"`==*.doc ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [ `basename "$f"`==*.pdf ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [ `basename "$f"`==*.txt ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
fi
done

It says Workflow completed but nothing printed and nothing came up for me to choose the printing options...

Am I doing this wrong? Yea I think I am

Jan 12, 2010 3:58 PM in response to Bone_Chaos

Bone_Chaos wrote:
OK ..
This is what I got and it does not work;

Get Specified Finder Items (Add, Remove)

Run Shell Script
Shell: /bin/bash Pass input: as arguments

for f in "$@"
do
if [ `basename "$f"`==*.doc ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [ `basename "$f"`==*.pdf ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [ `basename "$f"`==*.txt ]
then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
fi
done

It says Workflow completed but nothing printed and nothing came up for me to choose the printing options...

Am I doing this wrong? Yea I think I am

yes, you are. first, did you create a printer instance called lpr for your printer? if not this will not work. and if you did create it you are using the same printer instance in all commands. what's the point of that? I thought the point was to use different presets for different file types so you want one prnter instance for each. also, in that case there is no need for -o option. you should put that in the printer instance setting or not use printer instances at all. you are doing both. lastly, or perhaps firstly, the syntax is wrong in a couple of places. your printer name has spaces so you should enclose it in quotation makrs. also, the word filename does not belong there. what should be provided there is the path to the file in question. I made a mistake too and forgot to put it in.sorry about that. so the shell script action should look like this

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
for f in "$@"
do
if [ `basename "$f"`==*.doc ]
then
lpr -P "HP LaserJet P4014dn/lpr" "$f"
elif [ `basename "$f"`==*.pdf ]
then
lpr -P "HP LaserJet P4014dn/lpr" "$f"
elif [ `basename "$f"`==*.txt ]
then
lpr -P "HP LaserJet P4014dn/lpr" "$f"
fi
done</pre>

Jan 12, 2010 7:03 PM in response to Bone_Chaos

First of all, when posting code snippits, wrap them in


...your code here...


Next, when using == you need to use double [[ ... ]]

And finally, there must be a space before and after the ==

While I do not know if the following is working code, or if anything was lost when it was posted without the
wrappers, the following is valid syntax

for f in "$@"
do
if [[ `basename "$f"` == *.doc ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [[ `basename "$f"` == *.pdf ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
elif [[ `basename "$f"` == *.txt ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge filename
fi
done

For example, if filename is suppose to be the .txt, .pdf, .doc filename, then the code would most likely look like

for f in "$@"
do
if [[ `basename "$f"` == *.doc ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge "$f"
elif [[ `basename "$f"` == *.pdf ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge "$f"
elif [[ `basename "$f"` == *.txt ]]; then
lpr -P HP LaserJet P4014dn/lpr -o sides=two-sided-long-edge "$f"
fi
done
{code}

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator and Printing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.