# Relative paths without \`mediapath\`?

**URL:** https://gramps.discourse.group/t/relative-paths-without-mediapath/6383
**Category:** Development
**Tags:** website-generator
**Created:** [November 5, 2024, 9:42am UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383 "2024-11-05T09:42:39Z")
**Posts on this page:** 17
**Page:** 2

<div class="post-metadata">

### Author: ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)
#### Post date: [November 5, 2024, 4:28pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/21 "2024-11-05T16:28:56Z")

</div>

> [@bartfeenstra](#):
>
> Gramps API integration is planned for future releases, but that will require some work.

Feel free to ask if you need any help.

> [@bartfeenstra](#):
>
> One thing that would be incredibly helpful is the introduction of type hints to the Gramps code base.

This has already been agreed and we will start introducing type hints in the next release.

---

<div class="post-metadata">

### Author: ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)
#### Post date: [November 5, 2024, 4:32pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/22 "2024-11-05T16:32:18Z")

</div>

> [@Nick-Hall](#):
>
> > [@bartfeenstra](#):
> >
> > One thing that would be incredibly helpful is the introduction of type hints to the Gramps code base.
> 
> This has already been agreed and we will start introducing type hints in the next release.

In case you want to watch that GitHub discussion:

> <https://github.com/gramps-project/gramps/pull/1717#issuecomment-2222409813>
>
> Thanks for your review @QuLogic. This is now ready for merge. Then I can work on… adding type hints.

---

<div class="post-metadata">

### Author: ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)
#### Post date: [November 5, 2024, 4:35pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/23 "2024-11-05T16:35:15Z")

</div>

> [@emyoulation](#):
>
> Media object writer could convert Media paths to absolute on the fly.

@Nick-Hall

Would it be a reasonable enhancement request to add a Gramps XML and package **export option** to: “convert relative media paths to absolute”?

---

<div class="post-metadata">

### Author: ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)
#### Post date: [November 5, 2024, 4:53pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/24 "2024-11-05T16:53:20Z")

</div>

If you run Betty on another machine, there’s a big chance that its home or users directory is not exactly the same as on the machine that did the export. And in fact, it may even run another OS.

This means that even if you have a base media path, it may not work, and absolute paths may not work either. And in most cases, the user does or should know where the files really are, and should hence be able to specify a base path and/or a replacement path.

---

<div class="post-metadata">

### Author: ![bartfeenstra](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@bartfeenstra](https://gramps.discourse.group/u/bartfeenstra)
#### Post date: [November 5, 2024, 4:59pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/25 "2024-11-05T16:59:38Z")

</div>

Excellent work on adding type hints! I left a few comments based on my experience converting Betty from untyped to typed. I hope they’re useful 🙂

Updating Gramps to ensure a media path is set whenever an export is created, would solve my problem, and others (including migrating a family tree from one machine to another, assuming the same OS family). I’d be happy with such an update 🙂

---

<div class="post-metadata">

### Author: ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)
#### Post date: [November 5, 2024, 5:24pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/26 "2024-11-05T17:24:51Z")

</div>

> [@bartfeenstra](#):
>
> I left a few comments based on my experience converting Betty from untyped to typed. I hope they’re useful

Thank you. Any feedback is always appreciated and often very helpful.

---

<div class="post-metadata">

### Author: ![bartfeenstra](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@bartfeenstra](https://gramps.discourse.group/u/bartfeenstra)
#### Post date: [November 5, 2024, 9:54pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/27 "2024-11-05T21:54:16Z")

</div>

Thanks, everyone, for your comments! I went ahead and implemented a solution that raises a helpful error as soon as it encounters a file with a relative path, and the family tree XML does not specify a base media path: [Support relative file/media paths when loading Gramps family trees by bartfeenstra · Pull Request #2194 · bartfeenstra/betty · GitHub](https://github.com/bartfeenstra/betty/pull/2194/files#diff-36b982da2947219107ff4e7c8e6eec2b427ba4fbdaff894878c7c4d97b76eee8R507)

---

<div class="post-metadata">

### Author: ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)
#### Post date: [November 5, 2024, 10:27pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/28 "2024-11-05T22:27:29Z")

</div>

> [@emyoulation](#):
>
> Would it be a reasonable enhancement request to add a Gramps XML and package **export option** to: “convert relative media paths to absolute”?

It would probably be better to export the default media path if one isn’t defined in the settings.

---

<div class="post-metadata">

### Author: ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)
#### Post date: [November 6, 2024, 2:27pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/29 "2024-11-06T14:27:34Z")

</div>

> [@Nick-Hall](#):
>
> It would probably be better to export the default media path if one isn’t defined in the settings.

Submitted Feature Request

[0013493](https://gramps-project.org/bugs/view.php?id=13493): [XML export] include a default media path for those not explicitly…

---

<div class="post-metadata">

### Author: ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)
#### Post date: [November 6, 2024, 2:54pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/30 "2024-11-06T14:54:30Z")

</div>

Setting a default media path in an export would meet the needs of Betty. But what of the backup being imported into a new Gramps database. You would be setting a media path that the original did not have.

---

<div class="post-metadata">

### Author: ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)
#### Post date: [November 6, 2024, 3:21pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/31 "2024-11-06T15:21:13Z")

</div>

There are a number of issues that need to be resolved for importing XML with regards to media and their paths.

Right now, import chokes on repeated attempts to import a .gpkg archive. This is because the import first creates a folder for the Relative Path media files. It that folder already exists, the import fails with a very unhelpful message.

This could be resolved in any of 3 ways…

1. if the folder exists as a subfolder of a designated “temporary” folder, the destination folder could be removed (with confirmation) and recreated
2. the error dialog could include a hotlink to the destination folder. Then the users could manually resolve the conflict without having to discover where autonomously and transparently created a folder in a past action.
3. Gramps offers to continue the import but skip the Media portion of the restoration

A better but MUCH more complex option would be to compare the directory and MD5 checksums of the existing folder against the archive. Then flag differences kmissing, new, MD5 mismatches) with resolution options.

---

<div class="post-metadata">

### Author: ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)
#### Post date: [November 6, 2024, 9:03pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/32 "2024-11-06T21:03:29Z")

</div>

If you do an import, you may need to change the path to fit the directory structure on the importing machine, especially when you work with a different account on that, because that often leads to a different home directory.

And further on, the whole thing is futile, if you run Betty on a machine that doesn’t have a Gramps at all.

---

<div class="post-metadata">

### Author: ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)
#### Post date: [November 6, 2024, 9:53pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/33 "2024-11-06T21:53:21Z")

</div>

I like the idea of a base media path and I use it.

My issue is that if Gramps does not need a base path and will accept media without a path set, why on a backup/export is Gramps now saying the base path is needed.

On a major upgrade, I will often make the transition by doing an import, not letting Gramps ‘convert’ the database. If I did not have the base path previously set, after the import, I know have one. ???

---

<div class="post-metadata">

### Author: ![ennoborg](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/ennoborg/32/4659_2.png) [@ennoborg](https://gramps.discourse.group/u/ennoborg)
#### Post date: [November 6, 2024, 10:08pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/34 "2024-11-06T22:08:31Z")

</div>

> [@DaveSch](#):
>
> My issue is that if Gramps does not need a base path and will accept media without a path set, why on a backup/export is Gramps now saying the base path is needed.

Good point, and that may be a reason to keep it empty, because in that case, it moves with your home folder, and there is no reason to change it when you move to another machine.

And if that works, it can save us a lot of support ‘calls’.

---

<div class="post-metadata">

### Author: ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)
#### Post date: [November 6, 2024, 11:01pm UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/35 "2024-11-06T23:01:39Z")

</div>

Yes. This probably needs more thought.

---

<div class="post-metadata">

### Author: ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)
#### Post date: [November 7, 2024, 3:19am UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/36 "2024-11-07T03:19:58Z")

</div>

We should probably link an old (2008) MantisBT in the discussion. Any resolution here will resolve it too.

- [0002450](https://gramps-project.org/bugs/view.php?id=2450#c32262): photo import : media path can not be found

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)
#### Post date: [December 7, 2024, 3:20am UTC](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383/37 "2024-12-07T03:20:03Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://gramps.discourse.group/t/relative-paths-without-mediapath/6383.md?page=1)
