Jump to content

How to modify the content in {query}

Recommended Posts

Based on a File Filter, I want to go to two locations with Terminal, within the same Workflow.


Let's say the file filter path result is: ~/my/folder.

  1. The first part of the workflow will simply go to cd {query} which navigates to ~/my/folder.
  2. In the next part of the workflow, I want to keep the last part of the query – "folder" – i.e. the "Display Name" in the File Filter, and interject it in the path ~/my/other/folder.

I guess there might be multiple ways to achieve this, and the way I've been trying to figure out has been to modify the query via string replacements, so that ~/my/ becomes ~/my/other/


I have also tried to understand upstream variables and if it's possible to get the "Display Name" in the File Filter and simply take that variable and paste it into the path ~/my/other/ so that it becomes ~/my/other/{var} i.e. ~/my/other/folder, but I haven't succeeded.


Appreciate any help with this since I've spent almost an hour now with no results!

Edited by winterflags

Share this post

Link to post

Use the shell command basename:

basename ~/my/folder
# -> folder

So your alternative might look like:

name="$( basename "$query" )"
echo "~/my/other/$name"

(echo sends the output to the next workflow action.)

Share this post

Link to post

Hi @deanishe, thanks for your help!


I'm not sure if I'm quite getting how to do this in practice. Also, I'm not sure how to get the echo to work with the whole Terminal Command (it also does other stuff).


I've added some images just to make it more clear what I'm attempting:








Terminal Command:



(The last image is obviously not going to work with the echo, as it stands).

Edited by winterflags

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...