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.


    Python script to back up Photos to SD card or HDD

    Pythonista
    5
    21
    8733
    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.
    • cvp
      cvp @FlyingDiver last edited by

      @FlyingDiver Assume you have imported your photos in the camera roll, you could import them, via script, into a Pythonista local folder, and there, via edit/share/save to files copy all your folder on an USB drive, like here

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

        @FlyingDiver a (quick and dirty) script to show how to import, from the camera roll, all photos created after a specific date (ex: all new photos of a new day during your trip, if you run it each day) and to save them into Pythonista, up to you to specify a particular folder.
        So all exifs (taken date, device, eventual gps, ...) are also copied into the jpg file.

        from datetime import datetime
        from objc_util import *
        import photos
        
        d0 = datetime(2016,2,19)    # date of first photo to save
        all_assets = photos.get_assets()
        for asset in all_assets:
        	if asset.creation_date > d0:
        		file_name = str(ObjCInstance(asset).valueForKey_('filename'))
        		b = asset.get_image_data().getvalue()
        		with open(file_name, mode='wb') as fil:
        			fil.write(b)
        
        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @mikael last edited by

          @mikael for info, when I connect my Panasonic LUMIX to my iPad via the Apple USB adapter, a photo is accessed as

          /private/var/mobile/Library/LiveFiles/com.apple.filesystems.userfsd/NO NAME/DCIM/106_PANA/P1060745.JPG 
          
          mikael 1 Reply Last reply Reply Quote 0
          • mikael
            mikael @cvp last edited by

            @cvp, accessible from Pythonista?

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

              @mikael No, and I don't understand why Files app shows the usb connections but Pythonista "open external" does not 😢

              Édit: it is accessible if you, in Files app, manually select a file and share to a Pythonista script.

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

                Maybe it wasn't clear in my original post. I'm planning on doing the import using the Photos app. Then some initial culling of images. Then I want a script to backup any new images to external media. @cvp's post shows me how to get the images, which is great. But currently Pythonista can't write to the external media? I would have to use iOS "Share" to copy them from Pythonista's sandbox to the external media?

                cvp mikael 3 Replies Last reply Reply Quote 0
                • cvp
                  cvp @FlyingDiver last edited by cvp

                  @FlyingDiver Assume you import your photos in the photos app.
                  The script shows how to import them from the photos app to a Pythonista folder.

                  Yes to "I would have to use iOS "Share" to copy them from Pythonista's sandbox to the external media?"

                  Then, in Pythonista, you can copy a folder to an external device like I also show

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

                    @FlyingDiver Personally, I plug an USB drive/flash to an usb slot of my router and I'm able, via SMB, to copy local Pythonista files to a folder of my external drive.But, I agree that in holiday/trip you don't have a router

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

                      Hoping next version of Pythonista will allow access to USB drives

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

                        dialogs.pick_document() does not show an usb Drive but shortcut command "get file" shows it, thus I think it could be possible, but perhaps with iOS 13 functions in future Pythonista version.

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

                          @FlyingDiver with the new beta, and thus in the v3.3 arriving begin of next week, you will be able to open an external folder on an usb Drive (flash, sd, Drive) connected to your iPhone/iPad, and thus save on it your local photos.

                          1 Reply Last reply Reply Quote 0
                          • mikael
                            mikael @FlyingDiver last edited by mikael

                            @FlyingDiver, thus, a script like this should now be feasible:

                            1. (After you have imported and edited the photos.)
                            2. Opens the photo gallery.
                            3. You pick the first photo that should be backed up.
                            4. That photo and all newer photos are copied to the external drive, potentially to a specific folder created with today’s date or a running number.

                            Would that fit your use case?

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

                              @mikael it is what does my little scrip above, you only need to add a path in the file write, a path like some posts above.

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

                                @cvp, yes, indeed. I was just thinking about the usability, i.e. visually picking the first image to be saved.

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

                                  @mikael ok, sorry. Wen I go in holidays, I always backup my photos from my camera to my iPad, until now via wifi, via usb in the future. But often, I have a lot of photos per day and it is sometimes difficult to say/pick which is the first to save visually. And I give the today date (I back up in the evening) and it is done.

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

                                    @cvp what camera do you use? Just curious.

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

                                      @jmv38 Panasonic Lumix DMC-TZ40

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

                                        This post is deleted!
                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post
                                        Powered by NodeBB Forums | Contributors