Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Feature Request] A method that return the selected Finder items #153

Closed
fturcheti opened this issue Oct 21, 2021 · 4 comments
Closed
Assignees
Labels
api Issues related to API feature request New feature or improvement status: fixed in next release The issue will be closed once next release is available

Comments

@fturcheti
Copy link
Contributor

fturcheti commented Oct 21, 2021

Describe the feature and the current behavior/state.

A method that return the selected items in Finder (files and folders). I've asked @thomaspaulmann about this on Slack and he suggested something like getSelectedFile, that would fit nicely with getSelectedText. I'm not completely convinced by the naming though because the method would ideally return an array of finder items, something like this:

interface FinderItem {
  path: string;
  isFile: boolean;
  isDirectory: boolean;
}

And that could be used like this:

const selection = getSelectedFiles();
const files = selection.filter(item => item.isFile);
files.forEach(file => { console.log(file.path) });

Will this change the current api? How?

No.

Who will benefit with this feature?

Extensions that act on the selected files and/or folders, like #147 – Open Finder Selection With…. Some examples:

  • an extension with commands to open the selection with specific applications, so you could assign a keyboard shortcut to open files with your code editor for example;
  • an extension to upload the selected file to an online file sharing service;
  • an extension to display the summed size of the selected files;
  • an extension to compress the selected files;
  • an extension to convert the format of the selected image files.

Any Other info.

@fturcheti fturcheti added api Issues related to API feature request New feature or improvement labels Oct 21, 2021
@thomaspaulmann
Copy link
Member

Thanks for adding the issue. Good point on the multi selection and that it should return some array.

I wonder how this function should behave when the Finder isn't the frontmost application. Thoughts?

@fturcheti
Copy link
Contributor Author

fturcheti commented Oct 23, 2021

I wonder how this function should behave when the Finder isn't the frontmost application. Thoughts?

I don't see a practical use for this function when Finder isn't the frontmost application. And it can be confusing to return something if it is on the background. Maybe it should return some kind of error in that situation.

@mathieudutour mathieudutour added the status: fixed in next release The issue will be closed once next release is available label Dec 13, 2021
@mathieudutour mathieudutour self-assigned this Dec 13, 2021
@dzg
Copy link

dzg commented Dec 14, 2021

I would suggest making this behave like Launchbar's Instant Send. If frontmost selection is Finder items, that is what gets passed. If it is text (in any app), then that gets sent.

@mathieudutour
Copy link
Member

you can already access the selected text (in any app) with getSelectedText. This will add getSelectedFinderItems to get the finder items if it is the frontmost app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to API feature request New feature or improvement status: fixed in next release The issue will be closed once next release is available
Projects
None yet
Development

No branches or pull requests

4 participants