How to combine two image (png) files to print them in duplex using AppleScript - shell

Right, so I'll try and explain this as clearly as possible;
As soon as two files are placed in the folder, I want a Folder Action to
print these files - got that...
but, and this is my problem. At the moment it prints the files after each other, and I want to make sure that they are printed together, duplex.
so far I've got this:
on adding folder items to this_folder after receiving added_items
do shell script "defaults write com.apple.print.custompresets com.apple.print.lastPresetPref Duplex"
tell application "Finder" to print these_items
end adding folder items to
so I reckon I need to combine/append the two files - so the printer sees them as one, and only one print job is the result, thus creating a duplex printed file :D
would be awesome if you have tips/ideas on how to solve this!
cheers!

I found a python script written by Martin Michel which will combine multiple images into one file. It should help you solve your problem... find it here. You may want to use image events to resize the images first before passing it to this script so they will fit properly on one printed page.

You could create a simple Automator Folder action, which would create a multipage PDF from the added image files, then either print it directly in Automator, or pass it on to an AppleScript in order to set your printer preferences.

Related

how to show a dialog windows during applescript works

I wrote an applescript to convert a to b,
I want to show a dialog when script is working,
script first ask for a file and a folder from user, after this I want to show a dialog until my last dialog which say work is done.
I couldn’t find any help here or other sites regarding this way of implementing dialogs, thanks for you help.
to be clear, there is no way of having an input for steps, because it's doing a convert on one file only, but the file could be large & take some time, I'm looking for something that can input for example line of codes & progress depend on which line it's working right now or something else which start with the first line & close just before the end dialog

Need a solution to open a custom file, print it, close it, and move onto the next file

Forgive me if this is the wrong place to look for help, but I have a problem in need of a solution:
We have a large collection of files with unique names that only open up in a specific editor. Embroidery files specifically (.dst or .pof). What I would like to do is print a matching library of these files as .pdfs. So, what I am after is a script or program that will open the file in the editor, print it, close it, and then move onto the next file in the folder till all are output.
Does something like this exist? Is there a custom script I could execute that would accomplish this?

MacOSX Give alias/symlink label color but not original file

Hoi Stackoverflow,
i have a short question. Is it possible to set the label of an alias/symlink to a certain color without effecting other symlinks and the original file?
Lets say if have one main folder and different subgroups. Each subgroups contains symlinks to the files in the main folder.
I want know to color these symlinks according to some variables which is easily done with
osascript -e "tell application \"Finder\" to set label index of alias POSIX file \"$1\" to \"$2\""
Unfortunately this changes the label index of the main file as well as and the ones from all other symlinks to that particular file.
Thanks a lot in advance :-)

BBEdit AppleScript for reformatting multiple files

I'm looking to write an Applescript which will utilize BBEdit — loop through a ton of HTML files and autoformat them (so the indentation is easier to read).
So far I have:
tell application "BBEdit"
activate
open {file "Macintosh HD:TEST DIRECTORY:testfile copy 2.html"} with LF translation
(format mode hierarchical)
beep
display alert "Finished!"
end tell
This applies the transformation to a single file, but has anyone got any suggestions how to apply this to an unknown number of HTML files?
You've almost got it; the trick is that you want to loop through the files returned by open. Thus, you need something like this:
tell application "BBEdit"
set docs to open LIST_OF_FILES with LF translation
repeat with doc in docs
-- format doc
save doc
end repeat
beep -- Or even `say "Finished!" without waiting until completion`
-- if you want your computer to talk to you
display alert "Finished!"
end tell
As you can see, all you need to do is place your formatting code inside this loop (and don't forget to save the files!); the loop will set doc to each element of the list docs in turn, and run the body with that element. If you're not sure how to select the files, one way is choose file with multiple selections allowed; this will pop up a dialog box which will allow you to select as many files as you want. To use it, just replace LIST_OF_FILES with (choose file with multiple selections allowed).
BBEdit will perform a find/replace on any group of files you want. Just hit command+shift+f to bring up Multi-File Search instead of the basic find/replace window.
If you have more than one set of find/replace commands that you need to execute at the same time, you need a Text Factory. See here for details on how to set one up: http://www.barebones.com/products/bbedit/benefitsexercise.html
Does that help?
You should use the Text Factory feature for this. Under "File > New > Text Factory". Any operation you can perform on a single file can be done on any number of files and you can save the operation for future use.

Mac-Automator, How to pipe the output of a shell script to a GUI text box

The problem I face is this:
I would like to have in a context menu (when i right-click on a folder) an action to be executed and display the output to the user, inside, let's say, a text area window with a vertical scrolling bar. Suppose, that the action is just a shell script that executes a "find" command inside the given directory, searching for a specified pattern.
I have managed to implement it, up to this point, using Automator. What I cannot do is to pipe the output in a synchronous fashion (what is meant by "synchronous" is to have the output print to the user when is produced by the "find" command, and not after the command has finished) in a GUI.
I have spent sometime searching on this and I have come to the conclusion that XCode and Interface Builder have to be put into the play? Am I on the right track? Is there a straightforward and simple way in succeeding in this without having to dig into this framework?
Thank you very much,
Babis
You can have the shell script throw a dialog when it gets the result using http://cocoadialog.sourceforge.net/

Resources