Jump to content

How to use variables like file name, file path, file type for files


Recommended Posts

I would like to create a workflow to filter a group of files, and if the selected file is a md file from my Obsidian Vault, then open it right in Obsidian, otherwise just open them in default apps. Yet I have no idea how to use variables like the file type, file path in order to process the md files. Could you please tell me how to do that, or is there any other way to meet this requirement? (I know nearly nothing about programming so I’m not sure whether any type of scripts can realize this) I’ve attached a simple version of my workflow which doesn’t come up to my expectation though.

I would highly highly appreciate it if you could please help me about this!

Link to comment

Welcome @YuTang,

 

From your description you need neither variables nor programming, just a few objects.

 

Connect a File Filter (configured as you want to detect your files) to a Conditional. In the latter, set it to if {query} matches regex Library/Application Support/obsidian. Change the path to something else if you have Obsidian stored anywhere outside the default location.

DolpVPy.png

Finally, connect each to an Open File Action. In the top one set Obsidian as the app to open the passed-in files, in the other leave the default.

Link to comment

Thank you so much. yet another problem, Obsidian cannot open a markdown file directly, if I set the next step as open it in Obsidian, it will only launch Obsidian but not open the selected md file. It requires a path to open it in Obsidian using Obsidian URL Scheme, like obsidian://open?path=%2Fhome%2Fuser%2Fmy%20vault%2Fpath%2Fto%2Fmy%20note (obsidian://open?path={query}), yet I have no idea how to get its path as a variable, could you please give me some further instructions? thank u so so much!❤️

Link to comment
2 hours ago, YuTang said:

It requires a path to open it in Obsidian using Obsidian URL Scheme


What an odd limitation. Are you sure that’s the only way?

 

2 hours ago, YuTang said:

yet I have no idea how to get its path as a variable


Again, variables, don’t apply here, you can just pass the file path along. The {query} example you gave should work. If it doesn’t, what exactly is happening?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...