Place images in the same folder after compilation

I have a lot of images in Research folder, like this:


After compiling to HTML, I want these images to be placed in the same folder where project was compiled, so it should be like this:

                                         |-- Foo.html
                                         |-- image_01.png
                                         |-- image_02.png
                                         |-- etc.

Is there way to achieve it? Thanks, John.

That will be done automatically if the images are included in the text of the items that will be a part of the compiled output, so if you don’t necessarily want them to be in the output, you could just put them all at the end and delete that part with a text editor after compiling. Otherwise, what I sometimes do in cases like this is just export the folder of auxiliary files after compiling, with the File/Export/Files… command.

Thank you, AmberV. In my case, images are not included in text, because they are too large and numerous. So, I will use your second advice, about post-exporting. Not very convenient, though.

It will be a much better to have <$img> tag, like in Mac version. This would completely and gently resolve described problem.

True, though Windows does already have that capability if you use MultiMarkdown. Using that method of writing, you refer to the image with Caption, and if you link the filename to the image in the binder then that image will be exported along with the .html file upon compiling. It does mean using Markdown to write—but that does also mean you get a much cleaner HTML output too, so it might be worth it on those grounds alone.

Hm, very interseting, but works a bit different from what I’m expected.

If I understand you right, you said that I could place images in Research folder, and then add caption in the texts. But this doesn’t work. Images are not exported. This is a screenshot of what I’m saying about:


However, yes, this would work, but only if I add images somewhere in the text. Here is screenshot:

When you said about MultiMarkdown links, did you mean the 1st or the 2nd way? I’m asking because I don’t sure why the 1st way is not working – i.e. it’s my lack of skills or Scrivener just can’t do it.

Sorry for the lack of clarity, Scrivener doesn’t parse MultiMarkdown syntax directly like that, so with the examples you provided it is essentially unaware of these pieces of text being image references to files in your binder. To clue it in to what you want, you need to select the filename part within the parentheses and create a Scrivener Link pointing to the intended image. When you do that, the compiler will check the target of the link, and if it is an image it will export that image into the folder with the name generated by its binder name and file extension, and then it will rewrite (in the output, not the original) whatever text is hyperlinked to that image to update it with the actual filename on the disk. Thus you could put whatever text you want in there, it doesn’t even have to be the filename.

I’ve attached an example in case that still isn’t making sense. It was created on a Mac, but it should work fine. (42.7 KB)

Thank you very much, AmberV! But still doesn’t work. Tested on Windows 7 with last version of Scrivener. Here is compiled with MMD to HTML option:


By the way, after I removed the space in the link, the output is slightly different, but still, it doesn’t work, i.e. during the compilation image was not exported.



Odd, well that doesn’t look like it’s in a healthy state, sorry about that. It looks like the code is doubling up the syntax for some reason, which is understandably breaking the output. It really shouldn’t matter if there are spaces in the hyperlink or not, since as I say that whole thing should be rewritten with the filename of the exported graphic (did you check the HTML source? wouldn’t surprise me if they are just dumping “Test Image” into the src attribute, which naturally doesn’t exist). I guess you could try using the literal filename for the hyperlink as well as linking it in the fashion I demonstrated and see if that works.

If not, you might be better off with plan A for the moment then. I’ll make sure this is on bug list either way though.

Compiling the test project with Scrivener 1.9.7 using “MultiMarkdown to WebPage (.html)” works fine for me on Windows 10, but it does seem there’s a buggy limitation in that the image name (as it appears in the binder) must not have spaces. So working with it as “test_image” is fine, but changing the file name to “test image” produces the ![Caption of the image][Caption of the image](test image.png) line. Changing the anchor text doesn’t affect this, e.g. (TestImage), (Test_Image), and (Test Image) all work so long as the image is still called “test_image” and only a single link is applied to the name in parentheses (e.g. you can’t have “Test” and “Image” with two separate links, even if they point to the same file). It should be called “test_image.png” in the compiled folder.

Worth noting that even when the image name used a space and so broke the reference during compile, the image itself was still exported alongside the .html, it just wasn’t pulled into the page properly.

What’s odd here then is that the screenshot shows the image is still using the “test_image” name, so it seems like there must be a second scenario that’s causing the errors. Is the image even being exported in your case? What file name is it given?

On further thinking, the most likely scenario here is that the link itself got altered, so it’s not being converted and exporting the image during compile. Try selecting all the linked text (“Test Image”) in the editor, then right-clicking and choosing “Remove Link”. Then select it again and choose Edit > Scrivener Link > Research > test_image to reapply the internal link to the image and try the compile again.

Thanks again, AmberV. After I reinstalled Scrivener, the problem is gone – i.e. image is successfully exported during the compilation, and properly shown in the output file.

Also thanks to MimeticMouton. As MimeticMouton said, the filename in the binder must not have spaces: