Skip

How do I use either/or logic inside an OSX Automator action?
October 19, 2008 11:03 PM   Subscribe

How do I use either/or logic inside an OSX Automator action?

This seems SO bloody simple, but I can't for the life of me figure it out.

So I've got an Automator workflow that finds all of the files with an extension of .avi inside a certain folder, then does something with them. This works great, but what I REALLY want is for the workflow to search for all files in the folder that have an .avi *or* a .wmv extension. Is this possible?

I've tried "avi OR wmv", "avi {or} wmv", "avi "or" wmv" and anything else you could possible imagine.

The specific action I want to be able to put the either/or operator into is the "Filter Finder Items" action. This is a default Automator action that comes with OSX.

*beating head against desk*
posted by JPowers to Computers & Internet (4 answers total)
 
Automator is really, really limited. I haven't used it much at all, largely for that reason. I think your best bet is to use an applescript or shell script action to do the filtering.
posted by hattifattener at 12:00 AM on October 20, 2008


Is there any reason it has to be the "Filter Finder Items" action? Have you tried using the "Find Finder Items" action, set to look for files with extension equal to .avi in your folder of choice? Then add a second "Find Finder Items" action set to look for files with extension equal to .wmv? Not sure what you're attempting to do, but I was able to chain two "Find Finder Items" actions together to find files with two different extensions and copy the requested files to a new folder.
posted by emelenjr at 12:03 AM on October 20, 2008


Use an AppleScript action like the one below to replace the actions that get and filter the filenames.
on run {input, parameters}
	set l to {}
	
	tell application "Finder"
		get selection as alias list
		repeat with f in result
			if f's name extension is in {"avi", "wmv"} then set l to l & f
		end repeat
	end tell
	
	return l
end run

posted by kindall at 12:27 AM on October 20, 2008


Actually it would probably be better to just have the AppleScript do only the filtering, accepting as input the files from a previous action. That way you can more easily adapt it for other tasks. That'd be:
on run {input, parameters}

	set l to {}

	tell application "Finder"
		repeat with f in input
			if f's name extension is in {"avi", "wmv"} then set l to l & f
		end repeat
	end tell

	return l

end run


posted by kindall at 9:43 PM on October 20, 2008


« Older Banana Diet: Ive recently read...   |  When I lived in LA a few years... Newer »
This thread is closed to new comments.


Post