Jump to content
moun10addict

[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!

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post

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?

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post
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!

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.

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