Copy plain text content of RTF file to clipboard

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

My Hazel is watching a special folder for RTF files and I want to get the content of any new RTF file in my clipboard. I am using a shell script for that:

Code: Select all
#!/bin/bash
textutil -convert txt -stdout $1 | pbcopy


This works in the Terminal, but not in Hazel, I am always getting an empty clipboard there.

Is there a solution for this?
TheMaJa
 
Posts: 2
Joined: Wed Mar 23, 2016 9:03 am

A couple things to look at:
- Use the full path to any files/programs referenced. Hazel runs in a different context than in Terminal and you can't rely on the same environment variables.
- Use double-quotes around $1 ("$1"). If there are spaces in the path, it won't work unless you quote the argument.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for the fast reply!

The path was not the problem (tried that before), but the double-quotes solved my issue. Thanks again, topic solved!
TheMaJa
 
Posts: 2
Joined: Wed Mar 23, 2016 9:03 am


Return to Support