Jump to content

[SOLVED] Help building a simple(?) workflow


Recommended Posts

Hey all,

 

I'm not familiar at all with workflows and after some tinkering still can't figure out how to put together what seems would be a simple workflow. Here's an example what I'd like to do:

 

Trigger the workflow --> workflow asks for input --> I would input three numbers separated by spaces (16 3 9) --> workflow would copy the following to the clipboard: C16-D03-P09

 

Perhaps I would need to go the scripting route for this, but if it's possible to do this through Alfred's built-in workflows that would be great. 

 

Thanks in advance!

Link to comment

I don't think that's going to be possible without scripting, unless the numbers are always two-digit, one-digit, one-digit. If that is the case, you could use a Replace utility with a regular expression, but if not, you'll have to do the formatting with a scripting language that knows how to zero-pad digits.

Link to comment
7 hours ago, moun10addict said:

Perhaps I would need to go the scripting route for this, but if it's possible to do this through Alfred's built-in workflows that would be great. 

 

It isn’t clear if you’re comfortable with scripting. In case you’re not, this should work (Ruby, untested):

padded = ARGV[0].split(' ').map { |n| n.rjust(2, '0') }
print "C#{padded[0]}-D#{padded[1]}-P#{padded[2]}"

 

Connect a Keyword Input to a Run Script Action to a Copy to Clipboard Output. Since you’re comfortable with tinkering, you should be able to set those up.

Link to comment

On another but related topic,

 

I'm trying to input some basic logic in the default mergeclipboard workflow. Specifically, I'd like to add a number which would then "merge" the clipboard items from {clipboard} to {clipboard:number}. Is this even possible or would I have to write a separate script for this?

Link to comment
54 minutes ago, A Kim said:

Is this even possible or would I have to write a separate script for this?

 

I don't think it's possible without any scripting, simply because (it sounds like) you want to want to merge a variable number of items and Alfred doesn't have any support for loop constructs.

 

But you only need to write a script that generates and outputs the appropriate {clipboard}\n{clipboard:1}\n{clipboard:2}\n...{clipboard:N} macro pattern and plug that into a Copy to Clipboard action with its value set to {query}, then Alfred will expand the macro.

 

You don’t even have to use a JSON Config to do it, which is a little unfortunate because a lot of us use Markdown → BBCode workflows to write comments on the forum, and whenever you write {clipboard}, Alfred expands it when you run the workflow…

Edited by deanishe
Link to comment
On 5/12/2020 at 5:01 AM, vitor said:

 

It isn’t clear if you’re comfortable with scripting. In case you’re not, this should work (Ruby, untested):


padded = ARGV[0].split(' ').map { |n| n.rjust(2, '0') }
print "C#{padded[0]}-D#{padded[1]}-P#{padded[2]}"

 

Connect a Keyword Input to a Run Script Action to a Copy to Clipboard Output. Since you’re comfortable with tinkering, you should be able to set those up.

It took a little tinkering, as you suggested, but I got it to work, and it works beautifully! Saves me TONS of time since I have to input text in this format multiple times each day. Thanks SO much for your help!

Link to comment
  • vitor changed the title to [SOLVED] Help building a simple(?) workflow

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