# Media synchronization clarification

**URL:** <https://forums.ankiweb.net/t/media-synchronization-clarification/48785>\
**Category:** Help\
**Created:** [August 29, 2024, 2:01pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785 "2024-08-29T14:01:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![helitopia](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@helitopia](https://forums.ankiweb.net/u/helitopia)\
**Post date:** [August 29, 2024, 2:01pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/1 "2024-08-29T14:01:28Z")

</div>

Hello

First of all, thanks to everyone involved for the work you are doing in developing such immensely helpful system as Anki (and derivatives). When I first discovered the program I was fascinated with the fact that now I can learn anything from geography to programing as all the previous SRSs I tried were severely limited in functionality.

Seconldy, I am writing to clarify the logic of media synchronization:

According to [the documentation](https://docs.ankiweb.net/syncing.html#media) and [the post](https://forums.ankiweb.net/t/make-anki-detect-media-file-changes-when-synchronizing/27199):

> Anki will synchronize any sounds and images used by your notes. It will notice when media has been added or removed from your [media folder](https://docs.ankiweb.net/files.html#file-locations), but will not notice if you have edited some existing files without adding or removing any. To get your edits noticed, you need to add or remove a file as well.

The reason I am asking is I found that, in fact, for media refresh between Anki Desktop and AnkiDroid to happen there is no need to add or remove a file.

Here is an example case:

1. Create a card containing picture of lime green color and press sync:  

2. Sync AnkiDroid and check color displayed in a card:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/2/c/2ce6c04f5bf4102dd45a56c77d8eea528a10855a.png)

3. Change `1.jpg` file so that now color of picture is sun yellow:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/6/e/6e6a8c927d6a0da49080fe88f9f18a32a68afcd7.png)

4. Note, that viewing the same card in Anki Desktop will still show lime green, but after program reload it displays sun yellow (cache as the reason?):  

5. Sync Anki Desktop and subsequently sync AnkiDroid. Proceed to view the card. The display color is sun yellow:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/8/2/82b65de4438c4fa8194eae786dcaea3b9b11eec6.png)

6. Note that viewing the same card in AnkiWeb after picture update to sun yellow will still show lime green color. But, nevertheless, AnkiDroid displays sun yellow, so I assume the updated file is loaded to the server anyway.  

7. Also note, that unlike any other media update, the file change (color from lime green to sun yellow) is not immediately visible through explorer in media folder (EX File Manager is used on screenshots, reproduced in FV File Explorer app as well). Just after the restart of a device can you see the sun yellow color (is there a possibility that AnkiDroid loads media into cache, and only at some point (in my situation, after the restart) dumps it into media folder?):  

Please, explain whether I am missing something. And if not, then confirm that my assumption is correct (that is, editing a file without adding or removing any other media will prompt to load it to the server, and consequentially, to AnkiDroid and AnkiMobile)

The motivation for the post is [ongoing improvement](https://github.com/anki-geo/ultimate-geography/issues/638) of Ultimate Geography deck. In particular, [experimental deck with interactive map](https://github.com/anki-geo/ultimate-geography/discussions/649). The deck uses scripts from media folder. Since the first version of the deck was already released, for further improvement to work correctly we need to ensure that updated scripts are used across all the devices (think “scripts in media folder are synchronized successfully”)

---

<div class="post-metadata">

**Author:** ![helitopia](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@helitopia](https://forums.ankiweb.net/u/helitopia)\
**Post date:** [August 29, 2024, 3:13pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/2 "2024-08-29T15:13:32Z")

</div>

Additionally tried to perform the same steps for `_1.js` script that inserts “v1” or “v2” text into card via DOM:

```JavaScript
document.querySelector("body").prepend("v1 ");
// or
document.querySelector("body").prepend("v2 ");

```

What I figured out is that if I directly edit `_1.js` to insert “v2” instead of “v1”, sync Anki Desktop, then sync AnkiDroid - AnkiDroid will display “v1”, meaning the script is not synchronized.

On the other hand, if I create script “test.js”, make it insert “v2” and rename it into `_1.js` removing previous file version, AnkiDroid will display “v2”, meaning sync is successful.

So it seems that the sync does not work if you directly edit the file, but will if you create new file with edited original file content and then rename it into original file, removing previous version.

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [August 29, 2024, 3:46pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/3 "2024-08-29T15:46:14Z")

</div>

> [@helitopia](#):
>
> So it seems that the sync does not work if you directly edit the file, but will if you create new file with edited original file content and then rename it into original file, removing previous version.

I didn’t know that! I recently was syncing all my deletions because I thought Anki won’t recognise the files have changed in local.

The docs might need a little updation here.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [August 29, 2024, 5:23pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/4 "2024-08-29T17:23:25Z")

</div>

> **[Syncing with AnkiWeb - Anki Manual](https://docs.ankiweb.net/syncing.html#media)**
>
> Anki's user manual. Anki is a flashcard program that makes learning easier.

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [August 29, 2024, 6:18pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/5 "2024-08-29T18:18:43Z")

</div>

They quoted the manual but it was not very clear what the manual meant.

---

<div class="post-metadata">

**Author:** ![helitopia](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@helitopia](https://forums.ankiweb.net/u/helitopia)\
**Post date:** [August 29, 2024, 6:32pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/6 "2024-08-29T18:32:38Z")

</div>

It might be a good idea to specify that by “editing” is meant opening the file and directly making changes to it. Creating new file and renaming it to existing one (while removing original version) is not considered “editing” and will prompt mentioned media sync.

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [August 29, 2024, 7:10pm UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/7 "2024-08-29T19:10:00Z")

</div>

> [@helitopia](#):
>
> to specify that by “editing” is meant opening the file and directly making changes to it.

That is the conventional meaning of “editing.”

In your example you were replacing a file with a different file – which is not editing. That is adding and removing.

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [August 30, 2024, 4:45am UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/8 "2024-08-30T04:45:59Z")

</div>

> [@helitopia](#):
>
> Creating new file and renaming it to existing one (while removing original version) is not considered “editing” and will prompt mentioned media sync.

“If you replace an existing file with a new file, Anki will recognise it’s a different file when syncing.” This should be good? If you have feedback about any other section of the manual, I’ll be glad to hear.

---

<div class="post-metadata">

**Author:** ![helitopia](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@helitopia](https://forums.ankiweb.net/u/helitopia)\
**Post date:** [August 30, 2024, 6:58am UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/9 "2024-08-30T06:58:44Z")

</div>

Thank you all for participation in the topic.

Looking at it again, you are absolutely right, editing is really non-ambiguous word. Making a pause and reconsidering the issue helped me understand that.

> In your example you were replacing a file with a different file – which is not editing. That is adding and removing.

I assume we can agree that “adding and removing” can be summarized as “replacing”? It is probably what confused me - I haven’t thought about “replacing” as “adding and removing” at first (even though I literally described it as such :))

To avoid further confusions (and duplicated posts) might be considered the addition to docs of explicitly defined behavior of “replacing” and its implications on sync process. But that is completely up to you - active maintainers, to decide whether it is worth the hassle. If so, I will be glad to contribute to the docs.

Again, the issue is resolved, thanks to everyone involved.

Edit: Something along the lines " _It will notice when media has been added, removed **or replaced** in your [media folder](https://docs.ankiweb.net/files.html#file-locations)_".

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [August 30, 2024, 7:28am UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/10 "2024-08-30T07:28:19Z")

</div>

It sounds like you understand the issue well, so if you think that would help clarify things, of course you are welcome to propose this yourself with a pull request on Github. No need to defer to the “active maintainers” – many hands make light work!

> **[GitHub - ankitects/anki-manual: Anki's manual](https://github.com/ankitects/anki-manual)**
>
> Anki's manual

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [September 29, 2024, 7:28am UTC](https://forums.ankiweb.net/t/media-synchronization-clarification/48785/11 "2024-09-29T07:28:49Z")

</div>

Closed on September 29, 2024, 7:28am UTC

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