Jump to content
kodiak

Open Most Recent Download; pbcopy

Recommended Posts

Hi Everyone!

 

New to Alfred and its world of workflows.

 

I'm interested in creating my first two workflows. This is what I'm hoping to achieve:

 

1. Copy the contents of a text file (whether it's txt, nfo, html, rtf etc.) to the clipboard. I know there's a terminal command for that: pbcopy. I want to have this ability either through File Actions or as a workflow input.

 

2. Define a workflow input to open the most recently download file (in other words, the most recently added file in the macOS's Downloads folder).

 

Help would be very appreciated!

 

Thanks!

Share this post


Link to post
2 hours ago, vitor said:

because it’s so simple.

 

So simple but so powerful. I didn't know pbcopy would copy the file content like that. Thank you for sharing it.

Share this post


Link to post
4 hours ago, kodiak said:

I'm interested in creating my first two workflows.

 

If you wanted to do that for the learning process and have questions about how any of those work, ask away.

 

1 hour ago, nikivi said:

I didn't know pbcopy would copy the file content like that.

 

The secret there lies not with pbcopy, but with Bash. pbcopy’s task is “copy whatever I give you as input to the clipboard”. < means “take the file to the right of me as input to the command to the left of me”. If instead we had <<<, it’d mean “take the string to the right of me as input to the command to the left of me”.


So in this Workflow, if we had <<< instead of <, the clipboard would be populated with the path to the file instead of its contents.


Key phrases to search for if you want to learn more: “I/O redirection”, “here document”, “here string”.

Share this post


Link to post

Thanks @vitor! What kind of file extensions does your content copy workflow accept?

 

 

Edited by kodiak

Share this post


Link to post
4 hours ago, kodiak said:

What kind of file extensions does your content copy workflow accept?

 

Any, but it can be improved in that regard. On the File Action add +public.text as the file type, and it’ll only be available for text files.

Share this post


Link to post

1. What happens if I invoke the CopyContents workflow on .jpg or a very rich (photos, graphics and what not)?

2. Regarding RecentDownloads: how can I disable all keywords activating the workflow but "rda"? (but not erase them completely so I'll have future reference)

3. Is there any kind of a revisioning and/or backup mechanism available for workflow? Just in case I modify a workflow and want to do a rollback.

Share this post


Link to post

  1. Nothing bad. But you should modify the File Action as instructed (or download this version), so it doesn’t even give you the option.
  2. Double-click each Script Filter and delete the Keyword text.
  3. If you keep the original file and reopen it, it’ll replace the one you have installed.

Share this post


Link to post
On 3/3/2018 at 12:21 AM, vitor said:

If you wanted to do that for the learning process and have questions about how any of those work, ask away.

 

 

Much appreciated. I think I'll start first by examining the workflow themselves.

 

On 3/3/2018 at 2:33 PM, vitor said:

Any, but it can be improved in that regard. On the File Action add +public.text as the file type, and it’ll only be available for text files.

1

 

1. Can you elaborate on this a little bit? what does +public.txt represent (as a file type)?

 

Moreover:

 

2. If I delete the Keyword text, I won't have the original keyword handy in case I want to revert the changes, so I need to keep a backup. Right?

 

3. Can make a backup of my current workflows (those that are currently in their original state) by exporting them to another location?

 

Edited by kodiak

Share this post


Link to post

  1. It’s not a file type, but a Uniform Type Identifier (UTI).
  2. Technically yes, but you can have the Keyword be whatever you like, no need to save it. Alfred by default even keeps your changed Keyword on Workflow rewrite. Either way, most Workflows you can get them again by redownloading from the original source.
  3. Yes.

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