How to Open Mutliple Folders with a Sepecific Application (Gemini 2)

This is a suppose to be a simple Applescript but I have searched many post on macscripter.net and I cannot find anything that works.

Basically, “Gemini 2” is a duplicates finder (https://macpaw.com/gemini). I simply want to add all of the selected folders to open with the “Gemini 2” app but for some reason they are not being added to the application when it opens.

I have tested this script with other apps and it works fine. For some reason it is not working with “Gemini 2” even though I have the correct bundle identifier.

tell application "Finder"
	set sel to selection
	if sel is not {} then
		set filepath to item 1 of sel as text --> The path to the one selected item.
		open filepath using application file id "com.macpaw.site.Gemini2" -- bundle identifier of the designated application
	end if
end tell

You can check the bundle identifier yourself with the following code in terminal:
osascript -e ‘id of app “Gemini 2”’

With which other application were you running the script before ?

When I ran it to trigger BBEDIT, I got:

Don't click upon [Open this Scriplet in your Editor:]
tell application "Finder"
	get selection
		--> {document file "missing.rtf" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file "PDF matches_sehctam.txt" of folder "Desktop" of folder "**********" of folder "Users" of startup disk}
	get document file "missing.rtf" of folder "Desktop" of folder "**********" of folder "Users" of startup disk
		--> "SSD 1000:Users:**********:Desktop:missing.rtf"
	open "SSD 1000:Users:**********:Desktop:missing.rtf" using application file id "com.barebones.bbedit"
end tell

As you may see, I passed two selected text files (in fact a txt one and a rtf one).
The script took only the first one.
This action is ruled by the instruction :

set filepath to item 1 of sel as text --> The path to the one selected item.

then it asked BBEdit to open it which it did flawlessly.

Here when I ran the script to, trigger Gemini2, I got

Don't click upon [Open this Scriplet in your Editor:]
tell application "Finder"
	get selection
		--> {folder "cats" of folder "Desktop" of folder "**********" of folder "Users" of startup disk}
	get folder "cats" of folder "Desktop" of folder "**********" of folder "Users" of startup disk
		--> "SSD 1000:Users:**********:Desktop:cats:"
	open "SSD 1000:Users:**********:Desktop:cats:" using application file id "com.macpaw.site.Gemini2"
end tell

which seems to be perfectly logical.
1 - even if you selected several folders before running the script, only the first one will be triggered.
2 - after extracting this first item, the script urged the Finder to ask Gemini2 to open this one.
In real life, the Finder launched Gemini2 but this one is unable to execute what it is asked to achieve because it’s not AppleScript aware. It does exactly what it is able to do : start the scan of your disk.

It’s at least how I understand what is done.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 14:11:20

I have tested this script with an image compression application called Optimage (https://optimage.app/).

It supports multiple selections and it works fine.

tell application "Finder"
	set sel to selection
	if sel is not {} then
		set filepath to item 1 of sel as text
		open filepath using application file id "com.vmdanilov.optimage"
	end if
end tell

I will also like to add that “Gemini 2” does support selecting multiple folders since when you install the application, it adds a macOS “Service” in “Finder” where you can “Scan for Duplicates with Gemini 2” on the selected folders. But I do not want to do this manually for every folder. I am trying to create an automated workflow.

Maybe, the following is what you asked for:


tell application "Finder" to if selection is not {} then ¬
	open selection using application file id "com.macpaw.site.Gemini2"

@KniazidisR, thanks making the code much simpler. But the folders are still not being added to the application.

OK, select some folders in the Finder, then run the script. I tested with Gemini 2 on Mojave. It works.

I did select the folders in the finder and I just tested it with the code you provided and the folders are not being added. I have High Sierra and the last version of Gemini 2 installed. But I do not believe it is an issue with the Operating System.

So, what it does? Opens the previous scanning session results, stored on previous app running? What you see on the screen?

It just opens the app asking “Add or Drop Folders”

On my machine it opens window of Gemini 2 “Ready to scan!”. On the left side of window I see 2 selected folders. On the right side I see highlighted with green button Scan for duplicates.

Thanks for the effort. Guess I am going to have to either upgrade to Mojave, or find a different version of the app that works.

It’s not Gemini2 by itself which is unable to open two items simultaneously, it’s your script itself.
As I wrote carefully there is an instruction:

set filepath to item 1 of sel as text

which takes only the first item in the selection
then the script try to pass it to Gemini2.

It does exactly the same task when used to trigger an other application.
KniazidisR gave you an instruction which, triggering an other app (BBEdit for instance as I did) would open the several items passed.
Alas, as I wrote, Gemini2 is not AppleScript aware so it’s code, like yours is doing exactly what is done by a double click on the app icon.

@KniazidisR
If you go to : https://app.box.com/s/00qnssoyeq2xvc22ra4k you will get a zipped screenshot of what your script like mine open under 10.13.6

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 15:58:58

Even with two selected items, your script opens ONLY one image in Optimage.

Here is the reported history:


Don't click upon [Open this Scriplet in your Editor:]

tell application "Finder"
	get selection
		--> {document file "gerbino oiseaux.jpeg" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file "2011 026.png" of folder "Desktop" of folder "**********" of folder "Users" of startup disk}
	get document file "gerbino oiseaux.jpeg" of folder "Desktop" of folder "**********" of folder "Users" of startup disk
		--> "SSD 1000:Users:**********:Desktop:gerbino oiseaux.jpeg"
	open "SSD 1000:Users:**********:Desktop:gerbino oiseaux.jpeg" using application file id "com.vmdanilov.optimage"
end tell

You may see that two items were selected, a jpeg one and a png one.
As I already wrote several times, only the first item is sent to Optimage.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 16:21:56

On my side:
Folders I selected:

What I see in the Gemini 2 window:

@KniazidisR

As far as I know I didn’t wrote that you were wrong.
I described what is done under 10.13.6 which is the system used by kenexzo.

If you looked at the link which I gave you know that the app (version 2.5.7 here) doesn’t behave the same under 10.13.6 and under 10.14.x.

It appears that under new systems, when Gemini receive your instruction :

tell application "Finder" to if selection is not {} then ¬
	open selection using application file id "com.macpaw.site.Gemini2"

it’s able to execute it which it doesn’t under 10.13.6.

The application didn’t changed but the system is able to do new things - which after all - is why Apple’s engineers are paid.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 16:33:50

Corrected a typo. ‘the same under 10.13.6’ was erroneously spelled ‘the same under 10.12.6’

I tried to pass a screenshot. Never did before so I’m not sure that it works.

It doesn’t work.
The link passed was https://app.box.com/s/6mkaian80z14aby0e7p0c7z8v1uemcii
Click it to see the screenshot.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 16:56:01

  1. You should wrap screenshot’s direct link, (generated with special services, as FunkyIMG.com) with tags

  2. To get direct link, upload your screenshot to FunkyIMG.com.

You can quote my post with screenshots to see what I do

Maybe the old system can’t work directly with Finder selection. I am wondering if this works on High Sierra:


tell application "Finder"
	set sel to (get selection)
	if sel is not {} then open sel using application file id "com.macpaw.site.Gemini2"
end tell

or, at least, this:


tell application "Finder"
	set sel to (get selection)
	if sel is not {} then
		repeat with i from 1 to count of sel
			set aFolder to (item i of sel)
			open aFolder using application file id "com.macpaw.site.Gemini2"
		end repeat
	end if
end tell

I already posted what the script does under 10.13.6 (which is the late version of High Sierra)

Don't click upon [Open this Scriplet in your Editor:]
open "SSD 1000:Users:**********:Desktop:cats:" using application file id "com.macpaw.site.Gemini2"

The script issue this instruction which urge the Finder to ask Gemini2 to open the passed folder and the result is what you may see at https://app.box.com/s/6mkaian80z14aby0e7p0c7z8v1uemcii

Passing one or several files is not the problem.
It’s that under 10.13.6 and older systems, a file reference sent to the app is not treated by the app.
The fact that it is not AppleScript aware is not the real problem.

Libre Office doesn’t have AppleScript support but:

# select one or several doc files an try to run.
# Under 10.13.6 the passed documents are correctly open
tell application "Finder"
	set sel to (get selection)
	if sel is not {} then open sel using application file id "org.libreoffice.script"
end tell

Here is what History reported:

Don't click [Open this Scriplet in your Editor:]

tell application "Finder"
	get selection
		--> {document file " jury.doc" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file " sélection.doc" of folder "Desktop" of folder "**********" of folder "Users" of startup disk}
	open {document file " jury.doc" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file " sélection.doc" of folder "Desktop" of folder "**********" of folder "Users" of startup disk} using application file id "org.libreoffice.script"
end tell

Gimp doesn’t have AppleScript support and:

# select one or several picture files an try to run.
# Under 10.13.6 Gimp is activated but the passed documents aren't open
tell application "Finder"
	set sel to (get selection)
	if sel is not {} then open sel using application file id "org.gimp.gimp-2.10:"
end tell

Here is what History reported:

Don't click [Open this Scriplet in your Editor:]

tell application "Finder"
	get selection
		--> {document file "Screen-Shot-2019-12-19-at-12-56-19.png" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file "Screen-Shot-2019-12-17-at-07-35-40.png" of folder "Desktop" of folder "**********" of folder "Users" of startup disk}
	open {document file "Screen-Shot-2019-12-19-at-12-56-19.png" of folder "Desktop" of folder "**********" of folder "Users" of startup disk, document file "Screen-Shot-2019-12-17-at-07-35-40.png" of folder "Desktop" of folder "**********" of folder "Users" of startup disk} using application file id "org.gimp.gimp-2.10:"
end tell

As you may see both did exactly the same job but one really treated the files, the other didn’t.

What you get under 10.14 tell us that something changed and it’s not in the applications themselves.
I tested with the very late Gemini2 loaded only for these tests (it will go to the trash when this exchange will be closed).

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 18:40:04

In this quote in which I inserted some extraneous space characters you may see what I used and what you used.
The only difference is that app.box.com doesn’t behave like funkyimg.com

My late attempt taught me that passing a Box link to a picture file allow us to see the picture via a double click.
It’s sufficient for me.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 18:52:53

It’s clearly an issue with the operating system.
Under High Sierra (10.13.6) Gemini2 is activated but the folders aren’t added.
Under Mojave (10.14.x) the screenshot posted by KniazidisR prove that the folders are added to the app.
I tested with Gemini2 version 2.5.7 which is the late version available.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 22 décembre 2019 20:16:33