Welcome to MacForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Shell scripts

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Mac App to get CD track names (not imported using..  
Author Message
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 1) Posted: Sat Nov 22, 2008 6:25 pm
Post subject: Shell scripts
Archived from groups: alt>comp>lang>applescript (more info?)

Hello,

i want to merge a lot of images of a folder into a pdf-file. And to do
so, i thinked immediately to the unix- commands. I've had seen a 'to
do shell script' -routine years ago, where does exactly what i want to
do, but now i cannot remember how do re-write this again in my
Applescript!) ...help! the man-pages are too cryptic so that i can
deduce something, also because no or poor exercises and examples are
included....! Dam*ned man pages!

 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 3131



(Msg. 2) Posted: Sat Nov 22, 2008 9:47 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> i want to merge a lot of images of a folder into a pdf-file.

Im not not sure exactly what you mean by this. You want to print
multiple images into a single PDF file? Would that be one image per page
of the PDF, or would there be some sort of layout for multiple images
per page? Or would it be all images on a single page?

> And to do
> so, i thinked immediately to the unix- commands. I've had seen a 'to
> do shell script' -routine years ago, where does exactly what i want to
> do, but now i cannot remember how do re-write this again in my
> Applescript!) ...help! the man-pages are too cryptic so that i can
> deduce something, also because no or poor exercises and examples are
> included....! Dam*ned man pages!

The "do shell script" command is part of Standard Additions. So open
Script Editor, choose File > Open Dictionary, select Standard Additions,
and look for "do shell script".

--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR

 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Dave Balderstone

External


Since: Mar 21, 2006
Posts: 1675



(Msg. 3) Posted: Sat Nov 22, 2008 10:22 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Imported from groups: per prev. post (more info?)

This message is not archived
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 4) Posted: Sun Nov 23, 2008 4:15 am
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello,
i want a shell script command, where creates a pdf -file by merging
Jpg-files (or tiff-files) in this one, new print-format.
Then, this pdf- file has to be being created, saving it in the same
path of these image-files;
this means that i've 100 files of items, from where 50% are zip-files
and 50% are tiff-or jpg-files, both in the same path.
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 5) Posted: Sun Nov 23, 2008 11:02 am
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hey,


> 1. What will you do with these PDF files once they are created? I can't
> think of how they would be very useful.

i want to clean up with all these image files, converting these in one
PDF file

> 2. Are you worried at all about image quality degradation once they are
> in the PDF file?

No. But it would be fine, if the script compresses the images too. Not
to much, let's say Quality 80%, also a compression rate of only 20%


> 4. Does the PDF have to be created by a shell script, or would pure
> AppleScript do?

Yes. consumes minor CPU resources and works faster, at all this files

> I believe the Mac OS X built-in "Image Events" scripting addition will
> convert images to PDF for you; but I'm not sure if it will let you
> combine multiple images.

I've not found any information about converting images to PDF, (Image
Events Dictionary) but, but..
it had seemed for me too, that Image Event is capable to do this, hm..

> I'm afraid if you're looking for a command-line tool to convert images
> to PDF, this isn't really the right news group to ask. You'll probably
> have better luck with a Google web search of maybe a visit to
> <http://soureforge.net>.

I'll give it a look.


Look at this first code: (has changed the unix-commands for Leopard?)

tell application "Finder"
set results_folder to ((path to desktop) & "Pdfs" as text)
repeat with i from 1 to count items in front window
set this_item to item i of front window
if class of this_item is folder then
set new_name to name of this_item
set source_file to (this_item as alias)
--display dialog (source_file & return & return & new_name & return
& return & (folder of front window as alias) as text)
my process_item(source_file, new_name, results_folder)
end if
end repeat
end tell

on process_item(source_file, new_name, results_folder)
-- NOTE that the variable this_item is a file reference in alias
format
try
set the source_item to the quoted form of the POSIX path of the
source_file
set the target_path to the quoted form of the POSIX path of
(((results_folder as string) & new_name) as string)
with timeout of 900 seconds
do shell script ("pstopdf " & source_item & " -o " & target_path)
end timeout
on error error_message
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1
giving up after 120
end tell
end try
end process_item
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 6) Posted: Sun Nov 23, 2008 11:45 am
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>                         do shell script ("pstopdf " & source_item & " -o " & target_path)

this command is not the right one, it converts only the old postscript
-format into new pdf-files. I dont'know who to start, for shell script
tutorials. But, how being has sayd Jolly Roger, thats better to ask in
another forum. Thanks nevertheless.
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 3131



(Msg. 7) Posted: Sun Nov 23, 2008 12:01 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> Hello,
> i want a shell script command, where creates a pdf -file by merging
> Jpg-files (or tiff-files) in this one, new print-format.
> Then, this pdf- file has to be being created, saving it in the same
> path of these image-files;
> this means that i've 100 files of items, from where 50% are zip-files
> and 50% are tiff-or jpg-files, both in the same path.

A few questions:

1. What will you do with these PDF files once they are created? I can't
think of how they would be very useful.

2. Are you worried at all about image quality degradation once they are
in the PDF file?

3. Do you want to ignore all files (ZIP files, etc.) except the images
in the source folder, or did you want your script to unzip compressed
images in the folder?

4. Does the PDF have to be created by a shell script, or would pure
AppleScript do?

I believe the Mac OS X built-in "Image Events" scripting addition will
convert images to PDF for you; but I'm not sure if it will let you
combine multiple images.

I'm afraid if you're looking for a command-line tool to convert images
to PDF, this isn't really the right news group to ask. You'll probably
have better luck with a Google web search of maybe a visit to
<http://soureforge.net>.

--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 8) Posted: Sun Nov 23, 2008 3:26 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> i want to clean up with all these image files, converting these in one
> PDF file

Import them in a new iPhoto album, choose "Print" and use the "Save as
PDF" option.

Patrick
--
Patrick Stadelmann
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 3131



(Msg. 9) Posted: Sun Nov 23, 2008 4:47 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> Hello,
>
> i want to merge a lot of images of a folder into a pdf-file. And to do
> so, i thinked immediately to the unix- commands. I've had seen a 'to
> do shell script' -routine years ago, where does exactly what i want to
> do, but now i cannot remember how do re-write this again in my
> Applescript!) ...help! the man-pages are too cryptic so that i can
> deduce something, also because no or poor exercises and examples are
> included....! Dam*ned man pages!

Try this Automator action:

<http://tinyurl.com/56p7uz>

--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 10) Posted: Sun Nov 23, 2008 4:49 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 23 Nov, 23:47, Jolly Roger wrote:

Roger,


> Try this Automator action:
>
> <http://tinyurl.com/56p7uz>

who writes such scripts? this Automator-workflow is composed of 4
parts:
1)get selected finder items
2)sort finder items
3)Applescript (unfortunately, it does not work)
4)combine pdf pages
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 11) Posted: Sun Nov 23, 2008 4:58 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> who writes such scripts? this Automator-workflow is composed of 4
> parts:
> 1)get selected finder items
> 2)sort finder items
> 3)Applescript (unfortunately, it does not work)
> 4)combine pdf pages

i mean, its very interesting to read this kind of scripting.
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 30



(Msg. 12) Posted: Sun Nov 23, 2008 5:45 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>Changing the
script to handle folder selections would be relatively easy.

thats right! i'm of the same opinion.

>/System/Library/Printers/Libraries/convert command-line tool to convert
each image to PDF.

Yeah, in my new applescript its a basic part of the code.

Thanks very much for your help, Roger,
but i think that i'm burned out for today. i'm simply to tired to
write more one letter;i'll check and adjust the default selection
handler for tomorrow and i wish everybody a good night (is there a
difference between day and night if somebody works or sleeps ? i think
no. So, good night.)
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 3131



(Msg. 13) Posted: Sun Nov 23, 2008 7:11 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> On 23 Nov, 23:47, Jolly Roger wrote:
>
> Roger,
>
> > Try this Automator action:
> >
> > <http://tinyurl.com/56p7uz>
>
> who writes such scripts?

Whoever runs the web site hosting the action, I imagine.

> this Automator-workflow is composed of 4 parts:
> 1)get selected finder items
> 2)sort finder items
> 3)Applescript (unfortunately, it does not work)
> 4)combine pdf pages

The action works. It's just the AppleScript portion *assumes* you will
have selected image files (as opposed to having a *folder* selected). So
try it with images selected rather than a folder selected. Changing the
script to handle folder selections would be relatively easy.

Notice that the script uses the
/System/Library/Printers/Libraries/convert command-line tool to convert
each image to PDF. You could do *all* of the Automator action steps in
pure AppleScript quite easily. Mainly you would need to figure out how
Automator combines PDFs together in step 4 and do that in pure
AppleScript.

--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Sander Tekelenburg

External


Since: Nov 07, 2003
Posts: 448



(Msg. 14) Posted: Sun Nov 23, 2008 7:27 pm
Post subject: Re: Shell scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
Jo_y wrote:

> [...] I've had seen a 'to
> do shell script' -routine years ago, where does exactly what i want to
> do, but now i cannot remember how do re-write this again

How to use specific shell tools involves deciphering their man pages.
But how to (and how not to) use AppleScript's do shell script is
explained in detail at
<http://developer.apple.com/technotes/tn2002/tn2065.html>.

--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>

Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"
 >> Stay informed about: Shell scripts 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
run several scripts one after the other - I have a folder storing several maintenance script and I call them from another script: // tell app "finder" repeat with le_script in every item of folder le_dossier_de_scripts run script (le_script as alias) end repeat end tell // the problem...

Scripts Menu Shortcuts - Is there any way to set Keyboard Shortcuts for the scripts menu? Thanks.

Safari Scripts - GUI scripting beta? - http://www.apple.com/applescript/safari/ has a collection of scripts for Safari, many of which require the installation of a beta of GUI scripting. (other places linked to this page have other iApps mentioning User Interface scripting, but call it UI..

Looking for scripts for Akai's MESA program - Does anyone know of any? Regards, Nick. -- Check out my Guitar Tuition site http://www.fretbored.co.uk http://www.cubasics.com, making Cubase simple.

Applescript Studio: How do I include other scripts in my a.. - Hi My application uses a perl script to perform some extra processing. Where should I place the script within the project so that it is accessible from my applescript? Also, what is the process for creating a standalone application once I am happy..
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]