Image and Video collection object ?

Hello MacScripter community,

I am raising this to request a little help regarding the following matter:

I have been using A Better Finder Rename with a process of actions (named droplet) working similarly as an AppleScript Droplet i.e. processing files by Drag n Drop.
I actually created an Automator application containing several chained droplets to process folder contents.

The use case is to drag n Drop a directory containing usually pictures AND videos, on the droplet for it to process content of the directory.

Problem is that I have 2 different automator apps depending on the file type one for pictures and another one for videos.

Solution to this seems to be using an Applescript with a condition statement / filtering function to be able to “branch” to the appropriate automator application.

What I need (and I don’t get things done) IS to :

Sort of Filtering every Images and every Videos of the drag and dropped folder AND THEN
“pass” every pictures within drag n dropped folder to the automator app for pictures
“pass” every videos within drag n dropped folder to the automator app for videos

I know how to launch my droplet within an Applescript by receiving content of folder as input, and then
open input using POSIX file “/PathToMyDroplet/droplet.app”

But I did not manage to “properly create and transmit” the collection of pictures and collection of videos to the appropriate droplet.

My issue seems to be related to the type of object I should use / declare to temporarily store / bufferize pictures on one side and videos on the other side, and then pass these collection to my droplets.
→ I need to pass every files of one type at one time to the droplet (which is different to the many scripts that i can find which usually process file by file)

Any help regarding this very welcome, as I am sure it is nothig fancy…

thanks a lot

Petrich

Hi Petrich. Welcome to MacScripter.

Presumably your exisiting Automator droplets each begin with a “Get Folder Contents” action followed by a “Filter Finder Items” action. You could combine them into one droplet using the “Set Value of Variable” and “Get Value of Variable” actions listed under “Utilities”:

• Get Folder Contents
• Set Value of Variable (to memorise the folder contents). Either use the default name “Storage” or type in another one.
• Filter Finder Items (to filter for, say, pictures)
• (Whatever actions you use for pictures)
• Get Value of Variable (get the folder contents again). Use the same variable name as above.
• Filter Finder Items (to filter for, say, videos)
• (Whatever actions you use for videos)

But it seems to be very slow. Another way, as you suggest, is to use an AppleScript droplet to call the appropriate Automator droplet(s). For this, you’d have to delete the “Get Folder Items” and “Filter Finder Items” actions from each Automator applet and have an AppleScript droplet looking something like the one below. You’d need to edit it to make sure it had all the required extensions and the correct paths to your Automator droplets and then save it as an application:

property pictureExtensions : {"jpeg", "jpg", "pict", "tiff", "png"} -- Edit as required.
property videoExtensions : {"mpeg", "mpg", "mp4", "mov"} -- Ditto.

on open droppedItems
	tell application "Finder"
		set droppedItems to selection as alias list
		repeat with thisItem in droppedItems
			if (item thisItem's class is folder) then
				set pictureItems to (thisItem's items whose name extension is in pictureExtensions)
				if (pictureItems is not {}) then open pictureItems using application file "path:to:picture:handling:droplet.app" -- Edit as required.
				
				set videoItems to (thisItem's items whose name extension is in videoExtensions)
				if (videoItems is not {}) then open videoItems using application file "path:to:video:handling:droplet.app" -- Ditto.
			end if
		end repeat
	end tell
end open

Thank you so much Nigel for bringing this up !

Sorry for answering late, I have been traveling for a week!

Fisrt suggestion is actually very acceptable too and I did not even think I could manage to do that this way.

I’ll try both and report here in case anyone faces similar situation.

Thanks again