I want to move a Markdown file that was downloaded into my Documents folder into my Obsidian vault. Then I want to set it’s properties from a Dictionary, and open the note in Obsidian.
I used Get Contents of Documents, Get First Item and saved the File Path. Then I used it as the source file path for the Move File action, and I hard-coded + as destination folder. No matter what combination I try, I can’t get it to work.
Is this even possible with AFO Move File? Earlier, I had tried non-AFO Move File but that required txt extensions, and I think maybe it needed to be in iCloud Drive rather than Documents. What am I missing? It’s probably very simple, but I’m just not seeing it. Thanks.
I’m afraid it’s not possible w/ Rename/Move File. When you link a vault, you give AFO the permission to access that particular directory tree – but nothing outside it.
You’d have to fetch the file from its parent folder using a Get File from Folder action. This’d require you to explicitly allow folder access to that folder (stored in the action’s config for later/unsupervised use), and specify the file name. The result of that action would be a copy of that file, which you could then save in your vault using Save File. Example:
It’s first parameter would be your original file (either select it directly, or pass in the result from another built-in File-emitting action, like Get File from Folder or Select File etc. The 2nd parameter needs you to explicitly allow folder access to the target folder (just like described above). Unfortunately, we can’t pass any path here from an AFO action because you have to manually give that permission at least once for security reasons.
I’m already using a Shortcut that moves one or more Markdown files I’ve selected in the Finder into a specific folder into my Vault. I trigger the shortcut via a Quick Action and a keyboard shortcut. I added to this now the dictionary and a AFO action to add some properties. Not sure if this matches your requirements.
This Shortcut takes one or more files selected in the Finder and processes them one by one. At the beginning a small dictionary is defined that contains the properties you want to add to the Markdown files later.
For every item in the input the Shortcut checks the file extension. Only files ending in “md” are handled further. Valid Markdown files are moved into the selected folder inside the Obsidian vault on iCloud Drive.
After moving the file the Shortcut stores (only!) the file name in a variable. It’s not really necessary, but I had some trouble passing the name directly into the AFO action, so this workaround was the quickest workaround.
Finally the Shortcut calls “Set properties for note …” from AFO. The moved file is updated using the values from the dictionary so the note receives the defined properties.
Once all files have been processed the Shortcut ends.
Yes, that was very helpful. I was able to move the most recent Markdown file in my Downloads folder to my Obsidian Add (+) folder with specific properties.
Get contents of folder Downloads
Filter Get Contents of Folder where
File Extension is md
Sort Creation Date
Order: Latest First
Limit: Checked
Get: 1
Get First Item from Files
Get file from Downloads at path Item from List
Set variable fileName to Name
Save file File to folder + in vault Ideaverse
Dictionary (with properties)
Set properties for note at file path +/fileName in value Ideaverse with data from dictionary Dictionary
Run Hide AFO
This worked fine, although I notice that the properties are not in the same order as the Dictionary. Is there any way to maintain the order as I have in the Dictionary, or perhaps use something like Linter to reorder them according to a specific order?
I guess I was a little confused because the descriptions for the Obsidian File actions mention that AFO uses the file system rather than Obsidian APIs. However, it wasn’t clear that they still ONLY apply to files within the Obsidian vault just like the other AFO actions that are bound by the Obsidian vault for processing AFO actions.
I appreciate the help getting me unstuck, espcially since the non-AFO actions related to files and folders are not that clear either, especially when they can be used for local or iCloud files, file types, etc.
Thanks, Leif. I really appreciate this, and this allowed me some additional flexibility to move selected Markdown notes to Obsidian. I used the following Shortcut actions, and it worked great.
Receive Files from Quick Actions
Set variable todayISO to Current Date (Custom: yyyy-MM-dd’T’HH:mm)
Repeat with each item in Shortcut Input
If File Extension is md
Move Repeat Item to +
Set variable fileName to Name
Dictionary (with properties, including some values derived from Repeat Item)
Set properties to note at file path +/fileName in vault Ideaverse with data from dictionary Dictionary
Javascript objects (that’s how Action URI receives those dictionaries) are inherently unordered. It really depends on the JSON parser that processes the received data, and Actions URI uses what its environment (Obsidian) provides.
The Linter plugin is a good option, yes.
I guess I was a little confused because the descriptions for the Obsidian File actions mention that AFO uses the file system rather than Obsidian APIs. However, it wasn’t clear that they still ONLY apply to files within the Obsidian vault just like the other AFO actions that are bound by the Obsidian vault for processing AFO actions.
Good point, I’ll update the description. Thanks for the input!
I haven’t used Linter plugin before in Obsidian. Is it fairly easy to ensure certain property order using it, without imposing too many rules or restrictions on my notes in general?
That said: I really like Linter. Takes away a lot of busywork for me. I found some sane settings, enabled them, and stopped thinking about them. Cleans up semantics (e.g., H1 → H3 becomes H1 → H2 etc.), empty lines, that sort of thing.
It’s a matter of taste but as a developer, I am very used to automatic formatting (linting) so it was just a small step to enable it for my notes, too. They are pretty standard, though.
Thanks. That’s very helpful, and I have made the suggested YAML settings for Linter. I had the plugin installed, but I wasn’t familiar enough with what it might do so I have not enabled it before. I will give this a try, but it sounds like it do what I want with my property order.