Jump to content

JSON: How to get folder name/file name?


Recommended Posts

Hi

I bought Alfred 5 yesterday and I am doing a new workflow.

The workflow has one "JSON Config" block that receives a query from a "List Filter" block.

I want to set the variable "foldername" to the basename of the path that is in the query.

How should I do it??

 

This is the content of the JSON block:

 

{
  "alfredworkflow" : {
    "config" : {
      "scopes" : [
        "{query}"
      ]
    },
    "variables" : {
      "folder" : "{query}",
      "foldername" : "the name of the folder/file of the path of the query"
    }
  }
}

Link to comment
On 4/23/2023 at 5:38 PM, jordikt said:

I have tried with the Automation "Get path basename without extension". It works fine.

 

Alternatively, use Get Path Basename and tick the box to remove the extension.

 

On 4/23/2023 at 6:18 PM, Stephen_C said:

Sorry for misleading a little with the Get Path Dirname: I always forget which is which!

 

Check the tasks’ description, which may make it clear. Their names are like that because that’s the typical nomenclature. If it helps, a folder is a directory, which explains the dir.

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...