kodiak Posted March 2, 2018 Share Posted March 2, 2018 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! Link to comment
vitor Posted March 2, 2018 Share Posted March 2, 2018 Download. I use it myself, but haven’t shared it in the forum because it’s so simple. RecentDownloads. Use rda or rdn followed by ↵. kodiak 1 Link to comment
nikivi Posted March 2, 2018 Share Posted March 2, 2018 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. Link to comment
kodiak Posted March 2, 2018 Author Share Posted March 2, 2018 I'm speechless. Thank you so much @vitor, works beautifully! Link to comment
vitor Posted March 2, 2018 Share Posted March 2, 2018 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”. msa and nikivi 2 Link to comment
kodiak Posted March 3, 2018 Author Share Posted March 3, 2018 (edited) Thanks @vitor! What kind of file extensions does your content copy workflow accept? Edited March 3, 2018 by kodiak Link to comment
vitor Posted March 3, 2018 Share Posted March 3, 2018 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. Link to comment
kodiak Posted March 3, 2018 Author Share Posted March 3, 2018 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. Link to comment
vitor Posted March 3, 2018 Share Posted March 3, 2018 Nothing bad. But you should modify the File Action as instructed (or download this version), so it doesn’t even give you the option. Double-click each Script Filter and delete the Keyword text. If you keep the original file and reopen it, it’ll replace the one you have installed. kodiak 1 Link to comment
kodiak Posted March 4, 2018 Author Share Posted March 4, 2018 (edited) 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 March 4, 2018 by kodiak Link to comment
vitor Posted March 4, 2018 Share Posted March 4, 2018 It’s not a file type, but a Uniform Type Identifier (UTI). 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. Yes. kodiak 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now