omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Allowing the user to select a directory from the file system

    Pythonista
    directory folder
    3
    12
    1528
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jaalburquerque
      jaalburquerque last edited by

      Hello. I have begun writing a small script to play audio files contained in a certain directory (on the iCloud or in the iPhone file system). For this, I would like to allow the user to select the directory that contains the audio files. Looking at the documentation, I found that dialogs.pick_document() allows the user to select files from the file system. But when I test it, the dialog does not allow for a directory to be selected, only regular files. What I would like is for the user to be able to select a directory. It seems that if the right UTI is specified, this could be possible. I tried using the ‘public.directory’ and ‘public.folder’ types, but the dialog still does not allow me to select a directory. Would anyone have any idea as to what I need to do to allow the user to select a directory from the file system? I would really appreciate it.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        Try https://github.com/tdamdouni/Pythonista/blob/master/omz/File Picker.py

        You may need to customize to hide non-folders.

        1 Reply Last reply Reply Quote 0
        • jaalburquerque
          jaalburquerque last edited by

          Thanks again for your help. Have a good day again.

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @jaalburquerque last edited by

            @jaalburquerque done in Folder_Picker

            1 Reply Last reply Reply Quote 1
            • jaalburquerque
              jaalburquerque last edited by

              Would any of you know if it is possible to open a folder that is contained in the iPhone file system (“On My iPhone”) or in the iCloud Drive to play the audio files in that folder? The audio files are located in directories in both these locations.

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @jaalburquerque last edited by

                @jaalburquerque yes, via thé Open External Files of Pythonista

                1 Reply Last reply Reply Quote 0
                • jaalburquerque
                  jaalburquerque last edited by jaalburquerque

                  Thanks. And would you be able to tell me how I might use the “FolderPicker” script in my own script to open a directory either “On My iPhone” or on the iCloud Drive?

                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @jaalburquerque last edited by cvp

                    @jaalburquerque First, you have to create your own folder in "On my iPhone " or "iCloud Drive".
                    Then, you have to give access to this folder by opening it once manually via Pythonista External Files. Then, you will need to know the full path to access to this folder by creating a small py script in this folder with

                    import editor
                    print(editor.get_path())
                    

                    and run it to know the path
                    For instance, on My iPhone, it will be something like

                    /private/var/mobile/Containers/Shared/AppGroup/EF3F9065-AD98-4DE3-B5DB-21170E88B77F/File Provider Storage/MyFolder/a.py
                    
                    1 Reply Last reply Reply Quote 0
                    • jaalburquerque
                      jaalburquerque last edited by

                      Okay. I will try that. Thanks so much.

                      cvp 2 Replies Last reply Reply Quote 0
                      • cvp
                        cvp @jaalburquerque last edited by cvp

                        @jaalburquerque sorry, procédure not yet ended, ....then you have to use this path in folder_picker

                        	py_dir = folder_picker_dialog('Select a folder', root_dir='/private/var/mobile/Containers/Shared/AppGroup/EF3F9065-AD98-4DE3-B5DB-21170E88B77F/File Provider Storage/')
                        
                        1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @jaalburquerque last edited by

                          @jaalburquerque For instance, in "on my iPad ", I have some private folders, and I can see them like

                          1 Reply Last reply Reply Quote 0
                          • jaalburquerque
                            jaalburquerque last edited by

                            Okay. It is very clear. Thanks again.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors