# OT - Help w/ Terminal - textutil & pandoc rtf to markdown conversion

**URL:** <https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270>\
**Category:** RapidWeaver Classic\
**Created:** [July 19, 2017, 5:39pm UTC](https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270 "2017-07-19T17:39:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![1611mac](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/1611mac/32/5675_2.png) [@1611mac](https://forums.realmacsoftware.com/u/1611mac)\
**Post date:** [July 19, 2017, 5:39pm UTC](https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270/1 "2017-07-19T17:39:58Z")

</div>

I found [THIS](https://stackoverflow.com/questions/30448176/how-to-convert-rtf-to-markdown-on-the-unix-osx-command-line-similar-to-pandoc) on stackoverflow forum. Here is the command line itself:

> textutil -stdin -convert html -stdout | pandoc --from=html --to=markdown

Can someone explain stdin and stdout please as opposed to actual file names? I’m guessing that if in Terminal and I am “in” folder named “ABC” (cd “ABC”) this will run on all html files in that folder? I can’t seem to get this to work and my understanding is not good enough to troubleshoot.

Any help/comments appreciated. If you know a conversion tool from rtf to markdown would you let me know please. I basically need to retain bold and italic tags from the rtf.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [July 19, 2017, 6:25pm UTC](https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270/2 "2017-07-19T18:25:13Z")

</div>

stdin and stdout refer to reading the file from Unix standard in and writing to standard out.

So in the example above I would replace -stdin with your filename you wish to convert. It apears that the sample comand is “piping” `!` to another program called pandoc. Don’t thing thats a standard Mac terminal command, so you may need to install it.

---

<div class="post-metadata">

**Author:** ![1611mac](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/1611mac/32/5675_2.png) [@1611mac](https://forums.realmacsoftware.com/u/1611mac)\
**Post date:** [July 19, 2017, 6:37pm UTC](https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270/3 "2017-07-19T18:37:31Z")

</div>

Hi… thanks. Yes. I put in “hard” file names for input and output and I ran only the first half of the command and it did indeed work, converting RTF to HTML. The second half is for a pandoc HTML to RTF conversion. I do have Pandoc installed. I’ll test it separately also then see if I can put the two together. But I’ll probably just setup a macro to launch terminal and run the two separately with given filenames.

Could you expand on your statement:

> stdin and stdout refer to reading the file from Unix standard in and writing to standard out.

I don’t understand where it would read from and write to… I’ve tried looking it up but it’s like everyone expects the reader to know what that means.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [July 19, 2017, 6:59pm UTC](https://forums.realmacsoftware.com/t/ot-help-w-terminal-textutil-pandoc-rtf-to-markdown-conversion/15270/4 "2017-07-19T18:59:21Z")

</div>

The stdin is usually your keyboard unless you pipe the input from another process.  
stdout would go to your screen.

> <https://stackoverflow.com/questions/3385201/confused-about-stdin-stdout-and-stderr>

As for textutil and most terminal commands you can get to a manual by typing  
`man textutil`

when done type q for quit.  
or  
[https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/textutil.1.html](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/textutil.1.html)

Here is a good article with samples on converting with textutil:

> **[Convert a Text File to RTF, HTML, DOC, and more via Command Line](http://osxdaily.com/2011/07/06/convert-a-text-file-to-rtf-html-doc-and-more-via-command-line/)**
>
> Do you need to convert a text file to RTF, plain text TXT, HTML, DOC, or another familiar document format? The excellent textutil command line utility can make quick work of text file conversion an…
