@cvp awesome code, works like a charm 🙂 now I can choose a directory and get its URL, but.. I still can’t get it to list its content. I feel like I should use FileManager class for it (part of Foundation). I have completely no ObjC background, so I’m a little Daredevilling here, and here’s what I came up with in order to list the content of the chosen directory:
fileManager = ObjCClass("NSFileManager").alloc().init() fileManager.contentsOfDirectoryAtURL_includingPropertiesForKeys_options_error_(param,,4,None)
where param is the URL of the directory I got from your script. When I run the script it just crashes and Pythonista shuts down. Is python’s None type the equivalent of ObjC nil? I didn’t know how to pass enumeration options as the third parameter so I just put the default value there (based on the documentation). Could you help me with that as well?
I really tried to find a similar post that would help me sort my problem out but I didn’t succeed. The question is pretty straightforward - I want to process all of the text files within some (in this case) OneDrive directory mapped in Files.app. I know that because of sandboxing I couldn’t just hardcode the directory path in the script so I guess I would need to ask the user to choose the directory manually each time, but that’s fine. For now the biggest problem is that I have no idea how to set up the document picker dialog to let the user choose a directory instead of a file.
I would appreciate any help :)