Automatically include a filename in the preview from shortcut actions

How can I automatically include a filename in the preview from shortcut actions?

For example, for an image file IMG_xxxx saved in the vault.
The aim is to get ![[IMG_xxxx]] in the note body.

After (create note action), we add the (trigger command action) with a “preview” in the vault, so that ![[]] is added to the note body.

But how do we integrate our file reference?

Knowing that our file is in the vault with other similar files! And there are many of them, in the example we’ve chosen: IMG_1000 , IMG_1001, IMG_1002,… we want to choose one in particular for each preview we want for each new note created.

Hi @Aurelien_Cilla, welcome to the forum! I’m afraid I don’t fully understand what you’re trying to achieve. :grimacing:

So, you’re saving a file to the vault folder using a non-AFO Shortcuts action, and then want to get its file path from the vault root folder, is that it?

In my case, I retrieve images from the Internet from iphone safari by saving them in the native photo application. Then I select them by package>5 (because otherwise you can only send them by <5 directly to obsidian with iphone) from photo to save them in the obsidian vault file dedicated.

I’m doing this without shortcuts, because I can’t see how shortcuts could help me with this preliminary task.

On the other hand, in the next step, which is what I described in the first post, the shortcut application allows me to go faster.

I need to retrieve text from a website from each image (no shortcut so far), and create a new obsidian note that will contain the text for each image: the shortcut actions allow me to include the title text from the clipboard in a new note, and at this stage I’m unable to insert the image as a preview![[IMG.JPG]] directly into the body of the note (which I’d like to do :slight_smile:

I automatically add the ![[]] syntax, but it’s empty. I’d have to program shortcut to include IMG.JPG in ![[]] to obtain ![[IMG.JPG]].

And what complicates the task is that the images each have a unique number, for example IMG_5138.JPG

For each note, I need to insert the image corresponding to the preview title text, and all IMG_ are available at the root of the vault

I’ve found a solution:) here’s the full shortcut to my long descriptions :sweat_smile:

I think it can still be improved:

I’d like to add # in front of each word to be able to observe the distribution of terms by keyword and facilitate searches.

Nice! You could add a “Text” action between “Obtenir” & “Create Note” to assemble your note body in one go, i.e. set the text to ![[Nom]] (“Nom” being the variable), then use the Text result as the note body. That way, you’d only have one call to Obsidian, not three.

I’d like to add # in front of each word to be able to observe the distribution of terms by keyword and facilitate searches.

This’ll do the trick. The “Text” action isn’t strictly necessary, I only used it for demonstration purposes. Set the input for “Replace” to whatever variable you need.

I had succeeded in replacing “space” with “space#” but I had the problem of special characters, which forced me to correct it manually! thank you!

→✅The step saving you suggested works perfectly.

→❌However, the one below does not work(ios16)

Did you enable “regular expressions” in the “Replace” action?

1 Like

yes, that was it, I hadn’t activated it! I added a space in front of #$1 because the apostrophe’, for example, was sticking to # which prevented the keyword from being activated :wink:
Thanks to your corrections, the task runs even faster :slight_smile: