Jump to content

Multi-select file picker for User Configuration?

Recommended Posts

Right now the File Picker widget used in User Configuration only supports selecting a single item. It would be a nice enhancement to allow multiple selections.


In the meantime, how have workflow creators worked around that? My first thought was to use a text area, and then use a colon-separated list, similar to $PATH. My script could then parse it and separate the list into usable parts. That's not as user-friendly as it could be, and since my workflow already has a file picker I'd have to decide how to handle the situation where a user chooses something from the file picker and also enters something in the text area (does one take precedence? do I combine the inputs?, etc.) There's also the issue of a user accidentally putting in something that's just wrong and it being non-obvious to troubleshoot.




Here's an example use case in case I wasn't clear:


My workflow, Recent Files, is a search utility workflow. Users choose a top-level directory to use as a starting point for file/directory searches. Instead of choosing a single directory, such as $HOME, I'd like to give them the option of a selecting multiple directories to search (~/Documents, ~/Desktop, etc.). I could put in a text area that takes input such as:




This is easily parse-able, but subject to the problems I listed above.


A Different Idea, maybe better


I guess I could also allow the user to select a file instead of a directory, with the logic that if the file picker is a file, read the contents of the file to determine what directories to search (and use the ordinary behavior if the user selects a directory instead). That's probably a much better short-term solution, and it will be sufficient to support users who are comfortable creating text files. It might slow the workflow down a bit, and of course someone might try to use a Word document or some other format instead of a plain text file, but on the whole this is probably an acceptable solution.


Anyone have a better idea?

Link to comment

I shall be interested to see what other ideas people have because recently I was working on a workflow when I was trying to work out something similar: taking more than one path from a user via the User Configuration and using that to populate the scope of a file filter. My "working out” failed.



Link to comment

The File Picker works like a text field specifically so you can make more advanced stuff with it when needed. For example, in Automation Tasks it allows you to set it to a {var:} so it can use a dynamic path from somewhere else on the workflow. Having a simple File Picker add multiple paths via GUI wouldn’t really work interface-wise when paths are in wildly different directories. The approach you take is up to you, but in most situations the File Picker will still be a better approach because choosing one path is the norm. The Google Drive workflow uses a File Picker and allows multiple paths to be added with commas, making the common case easy and the uncommon case possible. It has worked like that since the early Alfred 5 days, it’s a very popular workflow, and there has been no reported confusion with that methodology. And I should know: I briefly made it only support one path (during the messy Google transition where it was unclear the way they’d go) and immediately got requests to add the multiple folder behaviour back (previously it was a Workflow Environment Variable, also separated by commas, which I also do in other workflows).

Link to comment

Well, I'm not sure I completely agree with "a simple File Picker add multiple paths via GUI wouldn’t really work interface-wise when paths are in wildly different directories", but maybe there's more to unpack in either what's considered "simple" or in the implementation details of this specific File Picker. (The macOS Finder, for example, can easily do multi-select, but again that could be an unfair comparison of Apples to oranges.)


As far as using some sort of field separator--wow! I knew that one could type in a file/directory name, but I hadn't realized the full implications of that. Very interesting, and thank you. I was able to implement this in my workflow, and I'll be updating it in the near future. I chose to use a colon-separated list instead of a comma-separated list both to stay with the convention used in the $PATH environment variable--and also because it seemed more likely that there would be filenames with commas than there would be with colons.


Thank you again for explaining this!

Link to comment

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
  • Create New...