Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vloryan

macrumors member
Original poster
Jan 11, 2014
57
0
Hi, i am very new to TERMINAL scripting. I would like to

1. Open the app via TERMINAL (that works fine with
Code:
open /Applications/JPEGmini.app
...

2. AND open all files from folder xyz in that app (i have no idea how to do this)

I hope someone can help me here!

Thanks! vlo
 
There are two parts to your number 2: getting a list of the files you want in "folder xyz", and opening them in your JPEGmini app.

For getting a list, look at "man ls" in terminal.

For opening them with your app, look at "man open".
 
Hi, i am very new to TERMINAL scripting. I would like to

1. Open the app via TERMINAL (that works fine with
Code:
open /Applications/JPEGmini.app
...

2. AND open all files from folder xyz in that app (i have no idea how to do this)

I hope someone can help me here!

Thanks! vlo

Try

Code:
open -a /Applications/JPEGmini.app path/to/folder/xyz/*
 
Thank you som much LPZ! Works. Almost :) As i cannot associate files (even JPEG) with JPEGmini i get an error when the app tries to open those files. So this is what i do manually:

1. Open the JPEGmini app

2. O > Choose Folder > the app NOW opens all these files.

Any chance to have maybe two scripts?
One that opens the app (already got that) and the other one that does the O job in that open app?

I'll run the with automator in the end.

Thanks so much for your help!
Vlo
 
Thank you som much LPZ! Works. Almost :)
I'll run the with automator in the end.

Thanks so much for your help!
Vlo

Since you've mentioned Terminal, have you considered jpegoptim? It's available via MacPorts. Or you can get the latest source from

http://www.kokkonen.net/tjko/projects.html

and compile it yourself.

Not sure about your level of expertise. Not sure how jpegoptim compares to JPEGmini as an optimizer. But since jpegoptim is a command line tool, you'd certainly be able to incorporate it into shell scripts.

Just something to consider.
 
Thanks for the advice, but jpegoptim is by far not as good in reducing jpg file size as JPEGmini. So is there a chance to have to terminal line for (2) from above?
 
Thanks for the advice, but jpegoptim is by far not as good in reducing jpg file size as JPEGmini. So is there a chance to have to terminal line for (2) from above?

After downloading the free JPEGmini Lite and playing around, I see no way of accomplishing (2) using Terminal.
 
You could probably do it using an AppleScript.

I haven't used AppleScript in over a year, and I never had much experience with it, but this sounds like the kind of thing that AppleScript does.
 
ok, so there is still hope. unfortunately i gave no idea how to fo that either :(
 
ok, so there is still hope. unfortunately i gave no idea how to fo that either :(

Thank goodness for the internet, where a person who knows nothing can do a little searching in their favorite search engine (IE, Google or DuckDuckGo) and learn how to do simple things in a new language.

You can look around and find lots of examples of opening applications in AppleScript and having it pick menu items.
 
ok, so there is still hope. unfortunately i gave no idea how to fo that either :(

Try this :

Applescript :

Code:
activate application "JPEGmini Lite"

tell application "System Events"
	tell application process "JPEGmini Lite"
		set frontmost to true
		click menu item "Open…" of menu 1 of menu bar item "File" of menu bar 1
	end tell
end tell

Shell script :

Code:
#!/bin/bash 

/usr/bin/osascript <<-EOF

activate application "JPEGmini Lite"

tell application "System Events"
	tell application process "JPEGmini Lite"
	set frontmost to true
	click menu item "Open…" of menu 1 of menu bar item "File" of menu bar 1
	end tell
end tell

EOF

Note : Change "JPEGmini Lite" to whatever you're using e.g. how it's named in the Applications folder. You need to give access to the UI in the Privacy --> Accessibility section for Applescript Editor and/or Terminal. If you're on Mavericks it will ask you to do so on the first run of the scripts.
 

Attachments

  • Screen Shot 2014-01-13 at 00.55.02.png
    Screen Shot 2014-01-13 at 00.55.02.png
    115.9 KB · Views: 138
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.