Is there a way to get the current directory from a File reference?


#1

If a user selects a file from the file dialog is there a way to get a reference to the folder the file is in? For example, if a user selects a file and you need to add additional files in the same directory you need to get the same folder to write to.

Use Case:
Jan is a designer at StarTupp, a tupperware company, working on their new app design.

She has been sending prototypes to the development team since last week. With each new change the developers have requesting she send the style guide. See below:

screenshot1

In the last two weeks the designs have changed multiple times and Jan is starting to see an opportunity to automate part of her workflow.

Now whenever she makes a change she opens her plugin, browses to the File she wants to export and clicks the Export button. Not only is her file exported but the updated style guides as well.


#2

bumping this. I am facing the same question.

From the documentation so far, I don’t see a way to do that, since it’s either file or folder.


#3

Is there actually a native dialog that supports choosing both? To my knowledge, at least on Windows, there isn’t. That would then make this kind of a two-edged sword, since it would mean going away from the native dialogs…


#4

The best practice for now would be to show a folder picker and then have your own UI to choose the file name(s) that will be written into the folder. The Folder object you get back from fs.getFolder() allows you to create any number of files inside that folder.