### Bug description


Hello!

The issues are .... 

1. When rendering a document to markdown format and such document generates images, the directory with the images is not moved to the output directory with the output file
2. When rendering a document with the `--output-dir` argument, it is ignored. (output is still in the source directory of the input)

## Reproducible Example

Using the nightly release of quarto, under mac os

````shell 
+ quarto --version
1.2.69
+ uname
Darwin
+ uname -r
21.6.0
````

Having this dummy directory structure as an example

````shell
+ tree
.
├── output
└── source
    └── file.qmd

2 directories, 1 file
````

Where the input file is this ... (simple file, generates a plot)

````shell
+ cat source/file.qmd

# This is a file

```{python}
print("Hello")

import matplotlib.pyplot as plt
import numpy as np

r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
  subplot_kw = {'projection': 'polar'} 
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```
````

And I run .... (render it with the `--output-dir` option)

````shell
+ quarto render source/file.qmd --output-dir output/ --to gfm

Executing 'file.ipynb'
  Cell 1/1...Done

pandoc 
  to: gfm+footnotes+tex_math_dollars-yaml_metadata_block
  output-file: file.md
  standalone: true
  default-image-extension: png
  
Output created: file.md
````

The output directory looks like this ...

````shell
+ tree
.
├── output
└── source
    ├── file.md
    ├── file.qmd
    └── file_files
        └── figure-gfm
            └── cell-2-output-2.png

4 directories, 3 files
````

Note how the file (`file.md`) is not in the desired output directory at all

A similar thing happens if I render it with the `--output-dir` option and `--output` option pointing to the (not yet existent) output file in the (already existing) output directory.

````shell
+ quarto render source/file.qmd --output-dir output/ --to gfm --output output/file.md

Executing 'file.ipynb'
  Cell 1/1...Done

pandoc --output ../output/file.md
  to: gfm+footnotes+tex_math_dollars-yaml_metadata_block
  standalone: true
  default-image-extension: png
  
Output created: ../output/file.md

+ tree
.
├── output
│   └── file.md
└── source
    ├── file.qmd
    └── file_files
        └── figure-gfm
            └── cell-2-output-2.png

4 directories, 3 files
```

Oddly enough, now the output file is in the correct location BUT the companion files are not

And the content of the output file is ...

````shell
+ cat img output/file.md
cat: img: No such file or directory

# This is a file

``` python
print("Hello")

import matplotlib.pyplot as plt
import numpy as np

r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
  subplot_kw = {'projection': 'polar'} 
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

    Hello

![](file_files/figure-gfm/cell-2-output-2.png)
````

Therefore, the file will not display correctly unless I move as well the `file_files` directory to the `output` directory.

Thanks a lot for the attention!

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
jjallaire
2022-09-07T06:53:51Z
jspaezp
bug
v1.2
closed
Render does not move companion files to output directory
https://github.com/quarto-dev/quarto-cli/issues/2329