Jump to content

Dynamic File Search with User Configured Variable


Recommended Posts

Hi all,

 

I'm trying to configure a file filter that has a dynamic search scope.

 

I'm aware we can use the JSON Utility and set the scope as a file path in a list, in the configs key. I wanted to set the scope based on a user configured variable (which is a file path that the user drags into the config).

 

I was trying to set it up but it wasn't working. The problem is:

 

  • When I set the scope manually I checked the file path and each file path (backslash) delimiter is escaped with a (forward slash) \.
  • When I access the variable (e.g {var:file_path}) it is not escaped.

 

Is there an easy way to make sure that when I pass in this variable to JSON Config it's properly escaped? Or do I have to write some script filter that escapes it manually and pass that JSON to the file filter?

 

Any suggestions will be much appreciated.

 

Thanks! 

Link to comment

For example when I add the path ~/Dropbox/notes, in the JSON Config is looks like  "~\/Dropbox\/notes.

 

Problem is in my Python script the file paths appear as usual without the escaping forward slashes.

 

Is there some way to transform the file path within Alfred or if not is there any documentation to how file paths should be formatted to be passed as arguments to consequent workflow objects so I can format them accordingly.

 

Thanks

Link to comment

Also for example @vitor,

 

In my Python script (using Script Filter) I am passing this path to the File Open object:

 

/Users/kostyafarber/Dropbox/notes/Adding Captions to a Figure.md'

 

But it's not being opened. This is the debug but nothing happens on my end.

 

image.thumb.png.ca44f1562c8a2d9b428a853e65313c6a.png

 

I know on Mac that spaces are escaped with forward slashes, maybe that's causing an issue?

 

If I do the exact same thing but with a File Filter Object and pass that to a File Open object I see the exact same thing in the debug but it works (my file is opened in the default application).

 

Why isn't it working when I pass the exact same path from a Script Filter?  

 

Unsure what's going on here.

 

Thanks.

Edited by kostyafarber
Tag someone
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...