On Sat, Aug 15, 2020 at 11:06 PM consiglieri <[email protected]> wrote:

> The problem I am having is that when running pandoc script in bbedit
script folder to convert a markdown file to
> pdf BBedit saves the generated pdf in a root folder and not in the same
folder as the mark-down file.,

It's hard to be exact without seeing your script, but let's use the basic
example pandoc command:

pandoc -o output.html input.txt

Now, if you are in your $HOME folder and ran this command:

pandoc -o output.html /some/other/folder/input.txt

then 'output.html' would be created in your $HOME folder, and not
"/some/other/folder/"

so what you really want is

pandoc -o /some/other/folder/output.html /some/other/folder/input.txt

There are a few ways of getting this. The usual way is `dirname`

If you add

DIR=$(dirname /some/other/folder/input.txt)

then DIR would equal /some/other/folder/

and you could use

pandoc -o "$DIR/output.html" /some/other/folder/input.txt

to get both files in the same directory.

So, going back to the BBEdit example, if `$BB_DOC_PATH` has the full path
to the file, you could use

DIR=$(dirname "$BB_DOC_PATH")

In zsh you don't need to use `dirname` you can use `:h` at the end of the
variable, like so:

DIR="$BB_DOC_PATH:h"

That will give you the `head` of the path, which is equal to the dirname.

Putting all of that together,

Example #1 (bash):

DIR=$(dirname "$BB_DOC_PATH")

pandoc -o "$DIR/output.html" "$BB_DOC_PATH"

Example #2 (zsh)

DIR="$BB_DOC_PATH:h"

pandoc -o "$DIR/output.html" "$BB_DOC_PATH"

I hope that's helpful. If you need more info, please feel free to ask.

Tj

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/CADjGqHt0KMDxweJuCPy%2BKNbT%2BnZ7z7hzLzmkBW1K_J_TwQ8Kyg%40mail.gmail.com.

Reply via email to