I assumed this would be the easiest Shortcut of all time, but it does not update the file name.
I have inserted Quick Look steps, and it pulls in the file name and converts the spaces to dashes just fine, but the file name does not get updated.
The files are in iCloud Drive (images), and I’ve tried this on image files within the Shortcuts folder in iCloud Drive, also with no luck.
Played around with it. Far as I got was to save it as a new file.
Strange that it doesn’t change the name of the file.
Not really. Your file object is independent of the file system. You are interacting with it outside of the file system.
Think of it like you downloaded a copy from the Internet, renamed it, then sent it back to the same place. It arrives as a new file with a new name.
The missing step is simply deleting the original file (with the original name) at the end.
Aha, so within the shortcut, it’s all “virtual” modifications, and you need to explicitly save the file (which results in a new/duplicate file). And since it’s in Shortcuts, it has to be saved within the Shortcuts folder if you want to save to iCloud Drive.
So my next question would be: can I pull the folder path from the existing file to auto-populate the /Shortcuts folder path? I’m using this as a Share Sheet action, so there is no Get File action step in the Shortcut to reference.
There’s no path information associated with the file that arrives in Shortcuts as far as I know.
Here’s the content graph for a ZIP file passed in via the share sheet.
The file component has just two parts.
The data is the file itself.
The NSstring is the file name.
And the only surfaced file attributes within Shortcuts are these.
I think the way Shortcuts receives the file is just as a copy, like an attachment to an e-mail. Imagine a file that is shared in through the identical share sheet mechanism from an e-mail app. The e-mail app could be storing that file in a database. It may save it to a temporary file at the point of exporting, but in no way is any information about the original ‘file’ location being sent, nor would it be meaningful unless Shortcuts also knew how to directly interact with he data structures in that particular database.
I can’t see a way you would unless you had a list of files that had that name and location, or searched for a match. Now that latter pointI guess would technically be possible utilising Scriptable to traverse the iCloud folder structure, but I suspect it would be inefficient.
Maybe pass the file into the shortcut, have the shortcut rename it and copy that name to the clipboard, then put you in Files, and then you manually rename the file utilising the clipboard. Cumbersome I know, but I’m just trying to think of anything that might help