Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change --extract-media destination folder #1986

Closed
m-baumgartner opened this issue Mar 3, 2015 · 7 comments
Closed

change --extract-media destination folder #1986

m-baumgartner opened this issue Mar 3, 2015 · 7 comments

Comments

@m-baumgartner
Copy link

The doc says the following :

--extract-media=DIR
Extract images and other media contained in a docx or epub container to the path DIR, creating it if necessary, and adjust the images references in the document so they point to the extracted files. This option only affects the docx and epub readers.

This works fine to me but it creates a /media folder in the specified DIR. How can I make pandoc puts the media file in a folder with a different name? eg. img

If this behaviour is not possible yet I think it this issue should be turned into a request.

Thanks

@jgm
Copy link
Owner

jgm commented Mar 3, 2015

+++ m-baumgartner [Mar 03 15 09:06 ]:

The doc says the following :

--extract-media=DIR
Extract images and other media contained in a docx or epub container to the path DIR, creating it if necessary, and adjust the images references in the document so they point to the extracted files. This option only affects the docx and epub readers.

This works fine to me but it creates a /media folder in the specified DIR.

This is because the files live in a /media folder inside the docx container. The relative path inside the docx container is preserved. Remember, --extract-media also works with epub, so we don't want to make its behavior dependent on details of a particular container. (Indeed, in an epub there is no particular location for media.)

How can I make pandoc puts the media file in a folder with a different name? eg. img

pandoc my.docx --extract-media=DIR && mv DIR/media DIR/img

@m-baumgartner
Copy link
Author

Thanks for your answer.
This partially work. The images are correctly moved to the defined DIR/img folder but the markdown links in the .md file still points to DIR/media instead of DIR/img.

@mpickering
Copy link
Collaborator

I'm not sure why we retain the media folder structure. I seem to remember there was some discussion about this when the feature was first implemented. @jkr do you remember why?

@jgm
Copy link
Owner

jgm commented Mar 4, 2015

+++ Matthew Pickering [Mar 03 15 15:50 ]:

I'm not sure why we retain the media folder structure. I seem to remember there was some discussion about this when the feature was first implemented. @jkr do you remember why?

I thought the reason was the one I gave earlier in this thread.
--extract-media works the same for docx and epub. But in epub, at
least, there's no particular place media has to be. You could have all
images in img, or in the top level, or some in one subdirectory and
some in another. So the only sane approach is to keep the internal
directory structure intact.

@nkalvi
Copy link

nkalvi commented Mar 4, 2015

Also, when you insert an image in current version of Word, it is saved under media folder in docx.

@mpickering
Copy link
Collaborator

Ah right, that makes sense.

@jgm
Copy link
Owner

jgm commented Mar 4, 2015

+++ m-baumgartner [Mar 03 15 11:44 ]:

Thanks for your answer.
This partially work. The images are correctly moved to the defined
DIR/img folder but the markdown links in the .md file still points to
DIR/media instead of DIR/img.

Oh, yes. I'd forgotten about that part of it. You could use a filter to change the paths on images.

@jgm jgm closed this as completed Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants