Jump to content

Add a workflow object (or add the option to the "Split Arg to Vars" object) that would split the query to an array


GuiB
 Share

Recommended Posts

Alfred workflow objects can work on array. For example, selecting multiple files in Finder and calling a "HotKey" trigger with a multi-selection will pass the files to an "Action in Alfred" workflow object and this latest object will interpret the passed query as multiple files (like an array).

 

However, when this query is manipulated and then moved back in Alfred domain from an object that only allows a single string return type (like the return of a "Arg and Vars" object or when we set the query into an environment variable) then this multi-argument query is converted to a single argument query with the items concatenated to a single string delimited with tab. Which is fine since this is a restriction from those methods, but then the problem is that we can't make use of the Alfred workflow objects that can interpret those multi-arguments query since it is now passed as a single argument.

 

We can work around this by using a "Run Script" and splitting the string into an array and then call from the script the wanted Alfred action using AppleScript or JSX, but we can't move back to chain into another Alfred workflow object or we need to do the same procedure with another "Run Script" and call from inside.

 

Therefore, it would be great if a new Workflow object could be created or the "Split Arg to Vars" could be modified to allow to output and pass a multi-arguments query to a chained object. For example, this would make it possible to pass an array of strings to be used by the new Text action with the "Action in Alfred" object and make workflows specific to array of strings. Also, this could make it easier for people to receive a value from an "External Trigger" and split it and use the standard Alfred workflow objects.

Link to comment
Share on other sites

  • 9 months later...
On 7/4/2021 at 10:07 AM, GuiB said:

We can work around this by using a "Run Script" and splitting the string into an array and then call from the script the wanted Alfred action using AppleScript or JSX, but we can't move back to chain into another Alfred workflow object or we need to do the same procedure with another "Run Script" and call from inside.

 

It sounds like you're saying that after Alfred converts an array of file paths to a string by virtue of assigning a variable, there's a way to re-convert that string back to an array that Alfred can read. Could you offer a little more detail on this? 

 

My use case:

 

I have a "move file" workflow that's ordinarily trigged by Universal Action from a single file, saves the filename/path as a variable, runs a File Filter to get a list of folders within a certain directory, holds the selected folder as the latest input and then uses "mv" in a bash script to move the file (from the file variable) to the selected folder (from the latest query).

 

But, this fails when I use the Universal Action on multiple files for the same reasons you mention above — if I try to save the paths of multiple files to a variable, Alfred now regards them as a single argument. So, I have to turn the script backward and make it run somewhat counterintuitively — first the File Filter asks for the destination folder (a single path, saved to a single variable), then it asks for the files to put in the folder — that way, the list of files are the latest query, and "mv" works in a for/do bash loop.

 

If — as it sounds like you were describing — there was a way I could pass the list of files in first, save them as a variable, then choose the folder, then convert the files string variable back to a list for using in the bash loop, that would be more ideal.

 

Here's a workflow demonstrating the issue, if that's of interest to anyone else:

 

https://drive.google.com/file/d/10WyyjVGDJTd4P79d8P4ikbTw1sPkeLwX/view?usp=drivesdk

 

Thanks!

Edited by brian_seidman
Update link
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...