I have created a hotfolder-based printing script...

As a necessity of my job, we need to be able to dump files tp a directory. This directory needs to be “watched” and should print any new files added to the directory. I have created a script (1st one!) that will do this - however, I need to refine it. Maybe some of you more experienced guys could help out? Here is my script as is is so far:

on adding folder items to this_folder after receiving these_items
tell application “GraphicConverter”
printfolder this_folder without dialog
end tell
tell application “Finder”
delete these_items
end tell
end adding folder items to

I attach this script as a folder action to a folder on one of our servers. I want to refine it a bit though…

  1. I want to be able to script which printer will be printing the files. Right now, the above script prints to the default printer. I have 2 other printers to incorporate. I am figuring I will need 3 seperate scripts, running on 3 different folders - I just need the syntax to input into each script to assign each to a specific printer.

p.s. If anyone wonders why I am employing GraphicConverter, as oppsosed to Finder printing - I ran into issues utilizing finder printing for .ps/.eps files

I have modified to script a bit…I added a portion that changes the default printer.

Is there a better way to do this though? Can I just send one of my files to the printer directly, without having to change the default printer in print center?

Here is the updated script:

on adding folder items to this_folder after receiving these_items
tell application “Printer Setup Utility”
activate
set current printer to printer (“Accel-a-writer 4g” as string)
quit
end tell
tell application “GraphicConverter”
printfolder this_folder without dialog
end tell
tell application “Finder”
move these_items to “vol1:proofers:printed:”
end tell
end adding folder items to

Thanks in advance guys :slight_smile:

that seems fine

you could consolidate some things

ie
tell application “Printer Setup Utility”
activate
set current printer to printer (“Accel-a-writer 4g” as string)
quit
end tell

could be this
tell application “Printer Setup Utility” to set current printer to printer¬ (“Accel-a-writer 4g” as string)

that could cut 4 lines of code

although you may not realize any time savings it is easier to look at

thank you Joe,

That was helpful. I have another question/scenario to ask about…

My script moves the files to a folder after it has been printed. I noticed that if a file exists in the “printed” folder already that is named identically to the file currently being printed - the ‘new’ file won’t move over.

I am curious, can I script the finder to append the name of the file it is attempting to move, if it finds an identically named one in the destination? Like if you download, for example, the same file twice - you will have two files, one appended in a way to differ from the first.

Thanks again guys :slight_smile:

just use an if clause

if exists theFile then
– rename the file then move it
else
–move theFile
end if

in rereading your post i see something else that may help you

UNTESTED kinda rushed sorry maybe incomlete

on adding folder items to this_folder after receiving these_items

 [color=blue]set[/color] [color=green]thePrinters[/color] [color=blue]to[/color] {"Accel-a-writer 4g", "printer #2", "printer Number 3"} [color=blue]as[/color] [color=blue]list[/color]
 [color=blue]set[/color] [color=green]chosen_Printer[/color] [color=blue]to[/color] [color=blue]choose from list[/color] [color=green]thePrinters[/color] [color=blue]with prompt[/color] "Please choose a Printer"
 [color=blue]tell[/color] [color=blue]application[/color] "Printer Setup Utility" [color=blue]to[/color] [color=blue]set[/color] [color=blue]current printer[/color] [color=blue]to[/color] [color=green]chosen_Printer[/color]
 [color=blue]tell[/color] [color=blue]application[/color] "GraphicConverter" [color=blue]to[/color] [color=blue]printfolder[/color] [color=green]this_folder[/color] [color=blue]without[/color] [color=blue]dialog[/color]
 [color=blue]repeat[/color] [color=blue]with[/color] [color=green]an_Item[/color] [color=blue]in[/color] [color=green]these_items[/color]
      [color=blue]if[/color] [color=blue]exists[/color] ("vol1:proofers:printed:" & [color=green]an_Item[/color]) [color=blue]then[/color]
           [color=blue]set[/color] [color=blue]name[/color] [color=blue]of[/color] [color=green]an_Item[/color] [color=blue]to[/color] ([color=blue]name[/color] [color=blue]of[/color] [color=green]an_Item[/color] & "01")
           [color=blue]move[/color] [color=green]an_Item[/color] [color=blue]to[/color] "vol1:proofers:printed:"
      [color=blue]else[/color]
           [color=blue]move[/color] [color=green]an_Item[/color] [color=blue]to[/color] "vol1:proofers:printed:"
      [color=blue]end[/color] [color=blue]if[/color]
 [color=blue]end[/color] [color=blue]repeat[/color]

end adding folder items to

this script was automatically tagged for
color coded syntax by Script to Markup Code
written by Jonathan Nathan

Joe, thanks for your attention to my topic here

your latest posting - this script will display a prompt to the user to select which printer?

That is a convenient feature, but my needs dictate this function should be entirely automated. So, for this purpose, asking the user to select the printer may not be efficient. Thanks for all your help though :slight_smile:

You Are Welcome

thats what this forum is all about
helping each other out

there are many things i would have never been able to figure out were it not for this great resource