Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
2 feature requests and soliciting a suggestion for workaround
-
I find it strange that there's no workflow action to list files in a local or dropbox folder and really wish a future version of Editorial would get one.
Also, the ability to specify a directory in the Sync with Dropbox action so that the whole thing isn't synced seems like a good thing to have.
In the meantime, any suggestions for how to accomplish at least the first of these two things? I've managed to hack together a solution that works but it makes me nervous relying on something like this:
import os import editor import glob import workflow db_folder = workflow.get_variable('foldername') db_path = os.path.split(editor.get_workflows_path())[0] + '/Dropbox/{}/*.*'.format(db_folder) files = glob.glob(db_path) workflow.set_variable('filelist', '\n'.join(files))
Has anyone figured out a better way to list all the files in a Dropbox folder (and a local folder, too, while we're at it)?
-
To list all files and directories at a path, why not use
os.listdir()
? If you want to recursively list files and directories, meaning you want to list all files, regardless of whether they are contained in a directory in another directory within the path you're listing, etc., you should useos.walk()
. Look up the documentation for these functions in the Editorial docs. -
Also, look into custom actions in workflows. That might help make your workflow cleaner.
-
Yeah, the actual listing of the files isn't so much the issue as it is getting the path to the folder. Using
workflow.get_workflows_path()
and then figuring out the path to the Dropbox folders by manipulating the path string seems really hacky to me and fraught with danger.For the purposes of this post, I just kept it to files only, non-recursive. I've since created a custom action that looks at either a Dropbox or Local folder, recursively walks the hierarchy and returns the resulting list as a JSON-formatted string. But the initial issue still remains.
-
The best way I can think of to do it would be to use
os.listdir(os.expanduser('~/Library/Application Support/Dropbox/'))
. I definitely wouldn't consider this "hacky", but I see where you're coming from. As long as you only modify, execute, and/or delete files visible to you in Editorial's UI in your code, you should be fine. Viewing and listing files does no harm at all. Outside of Editorial, iOS enforces strict restrictions on file access so you don't mess anything up. -
As long as you only list/read files in
~/Library/Application Support/Dropbox/
, that's fine, but I would strongly recommend not writing or deleting anything there. The sync mechanism isn't really prepared for that.