IOS Photo gallery items renamed and shared to iCloud ...is it possible?

question

#1

I would like to Share photos and videos from the iOS Photos app to a Scriptable shortcut to set the file names and move them (copy/delete) to a specified iCloud folder —is this achievable?

Kind Regards,
Sway


#2

Yes, this is achievable.

First, import the image with args.images, then ask for the new filename with an alert and put everything in DocumentPicker.exportImage(image, name). And you should be done!


#4

Man that seemed too easy…

That’s the essence of it except:
-I want to do multiple images without having to select the directory at all
-when I supply a name without an extension, it saves the image as an 8k dud… but I can’t sort out how to “read” the image(s) for their filename and/or extension

Is there any other documentation for the image object?


#5

Have you tried the online documentation referenced in the app. I’m not sure it’ll help with a file name. You may just need to programmatically or manually append that/set a file name.

https://docs.scriptable.app/image/

Do note that if you do not want to select an iCloud directory manually, you’ll need to save to a Scriptable directory.


#6

Saving it to the Scriptable directory is preferable.

I can’t set the extension statically because I don’t know what will image/video types will be feeding through the script. They will be coming from the iOS photo gallery so they should be readable by the Photos class they have. The class doesn’t seem to have a way of exposing what type of image or the name/extension of the image.

I thought perhaps it has to be handed off to the FileManager API but I haven’t found a successful way of that.

The last part is what is the base iCloud file path to the scriptable folder?
I tried relative paths without success

Edited to add:

I’m basically trying to do this…

let fm = FileManager.iCloud()
let folder = fm.documentsDirectory() + '/Testing/'

for( image in args.images ){
    let filePath = 'NewFile ' + image.creationDate + ' (' + image.name + ').' + image.extension;
    fm.saveFile( image, folder + filePath);    
  }

but the methods aren’t available, when really they should be. iOS Shortcuts is able to read and expose file information on the Photos Gallery even back when it was a 3rd party app Workflow.

…just a little frustrated