# Open In External Editor, Rename, Duplicate for Image, Audio,Video \[Official thread\]

**URL:** <https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555>\
**Category:** Add-ons\
**Created:** [June 27, 2020, 6:41pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555 "2020-06-27T18:41:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [June 27, 2020, 6:41pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/1 "2020-06-27T18:41:05Z")

</div>

If you have a problem with the add-on add-on [OpenInExternalEditor,Rename,Duplicate for Image,Audio,Video](https://ankiweb.net/shared/info/1560623518) post in this thread. This way I get notified. If you make a new thread I might miss it.

---

<div class="post-metadata">

**Author:** ![tricerbero](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@tricerbero](https://forums.ankiweb.net/u/tricerbero)\
**Post date:** [July 29, 2020, 3:25am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/2 "2020-07-29T03:25:35Z")

</div>

Hello, I’m trying to open a card field in VSCode for Mac by setting the option to “code” or “code --wait” with no luck. The textfield flashes but nothing happens. The only way it works is if I set “open -t” in the options, but then VSCode doesn’t save back to the field.

I’m running Anki 2.1.28 and VSCode 1.47.3 on MacOS 10.14.6.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [July 29, 2020, 9:35am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/3 "2020-07-29T09:35:28Z")

</div>

The add-on “OpenInExternalEditor,Rename,Duplicate for **Image,Audio,Video** ” is meant to edit image, audio, and video files in an image editor like paint or audio editor like audacity. I would never use VSCode for this.

If you want to edit the html source code in VSCode I would use [External Editor](https://ankiweb.net/shared/info/16727059), if you want to edit some latex maybe [text editor for Latex, the selection or html source (FORK)](https://ankiweb.net/shared/info/1184418999).

You write about “the option” but my add-on has about 20 different config options so I don’t know what you mean. If you really want to use my add-on here I need more info like the whole config and exact steps you take and how this could work with VSCode.

---

<div class="post-metadata">

**Author:** ![tricerbero](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@tricerbero](https://forums.ankiweb.net/u/tricerbero)\
**Post date:** [July 29, 2020, 12:46pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/4 "2020-07-29T12:46:42Z")

</div>

Sorry I’m already using External Editor, I just posted in the wrong thread!

---

<div class="post-metadata">

**Author:** ![hrdom](https://avatars.discourse-cdn.com/v4/letter/h/e274bd/32.png) [@hrdom](https://forums.ankiweb.net/u/hrdom)\
**Post date:** [August 9, 2020, 10:02am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/5 "2020-08-09T10:02:06Z")

</div>

Hello, I want to edit image on Win10 with its built-in software"Photos" ,  
but I can’t find its path, so I can’t add it to add-on’s configuration.  
Win10‘s built-in software seems can’t to find their path.  
Could you give me some help?  
Thanks.

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [August 9, 2020, 10:57am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/6 "2020-08-09T10:57:43Z")

</div>

@hrdom: If you google for something like “windows store app cli” you should find guides on how to find their path, see e.g. [here](https://www.addictivetips.com/windows-tips/open-uwp-apps-from-command-line-windows-10/).

But that’s not enough. The add-on passes the filename as a command line argument to the binary. But as far as I see app store apps often don’t take command line arguments. So even if you have find the path you might fail. I have no solution for this. I just use regular windows apps that I installed myself like paint .net.

Instead of my add-on maybe also have a look at [Image Editor](https://ankiweb.net/shared/info/307397307). I have never used this add-on but it seems to be independent from your local apps so that you don’t have the problem of calling an external binary.

---

<div class="post-metadata">

**Author:** ![hrdom](https://avatars.discourse-cdn.com/v4/letter/h/e274bd/32.png) [@hrdom](https://forums.ankiweb.net/u/hrdom)\
**Post date:** [August 9, 2020, 11:05am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/7 "2020-08-09T11:05:20Z")

</div>

Thank you.  
I’ll have a look and decide to use regular windows apps if it has some problem.

---

<div class="post-metadata">

**Author:** ![benten](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@benten](https://forums.ankiweb.net/u/benten)\
**Post date:** [August 30, 2020, 6:35pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/8 "2020-08-30T18:35:49Z")

</div>

Hello,  
I’m using anki version 2.1.5 on Windows 10 and when I am trying to install your addon, it’s says that either the code is invalid, or that it’s not available for my version.  
Is there a way to make it work ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [August 30, 2020, 10:09pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/9 "2020-08-30T22:09:25Z")

</div>

@benten: My add-on depends on features that were introduced in Anki 2.1. **15**. So 2.1.5 is too old. As an add-on uploader I can set compatibility info and I set on Ankiweb that only users with 2.1.15 or newer can install it. So you would need a newer Anki version to use my add-on.

---

<div class="post-metadata">

**Author:** ![IzzakKK](https://avatars.discourse-cdn.com/v4/letter/i/958977/32.png) [@IzzakKK](https://forums.ankiweb.net/u/IzzakKK)\
**Post date:** [June 16, 2021, 3:52am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/10 "2021-06-16T03:52:36Z")

</div>

Hi, i want to edit video and there is a [video editing software](https://www.tuneskit.com/video-editor/) on Windows 10, i don’t know if it’s useful.Can you please recommend the software you use or give me some advice?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![OjisanSeiuchi](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/ojisanseiuchi/32/2578_2.png) [@OjisanSeiuchi](https://forums.ankiweb.net/u/OjisanSeiuchi)\
**Post date:** [December 18, 2021, 4:14pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/12 "2021-12-18T16:14:29Z")

</div>

[Bug report]

The image rename doesn’t handle Cyrillic characters. (Would submit a PR on Github, but it looks like the repo has been removed…) In any case, here’s the exception:

```auto
Traceback (most recent call last):
  File "aqt/webview.py", line 526, in handler
  File "aqt/editor.py", line 534, in <lambda>
  File "/Users/alan/Library/Application Support/Anki2/addons21/1560623518/edit_insert_rename_duplicate.py", line 79, in <lambda>
    editor.saveNow(lambda: func(editor, fname, type, field))
  File "/Users/alan/Library/Application Support/Anki2/addons21/1560623518/rename.py", line 154, in rename
    backup_changed_filenames(fname, newfilename)
  File "/Users/alan/Library/Application Support/Anki2/addons21/1560623518/rename.py", line 123, in backup_changed_filenames
    targetfile.write(f"{old}\t{new}")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 52-56: ordinal not in range(128)

```

[LATER]

I believe this addresses the exception (basically, just open the logging csv file with UTF-8 encoding.)

```auto
def backup_changed_filenames(old, new):
    addon_dir_path = os.path.join(os.path.dirname( __file__ ))
    renamed_file = os.path.join(addon_dir_path, "user_files", "renamed_files.csv")
    with open(renamed_file, "a", encoding='utf-8') as targetfile:
        targetfile.write(f"{old}\t{new}\n")

```

Also added a newline after each log entry…

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [December 18, 2021, 8:50pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/13 "2021-12-18T20:50:05Z")

</div>

@OjisanSeiuchi : Thanks for fixing this bug. I just uploaded a new version to ankiweb. If you find other problems or have other fixes please let me know. I removed the github repo because I often forgot to push changes I made and I figured no repo is better than a dated one (at least as long as you can get my most current version from ankiweb).

---

<div class="post-metadata">

**Author:** ![OjisanSeiuchi](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/ojisanseiuchi/32/2578_2.png) [@OjisanSeiuchi](https://forums.ankiweb.net/u/OjisanSeiuchi)\
**Post date:** [December 18, 2021, 11:47pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/14 "2021-12-18T23:47:54Z")

</div>

@ijgnd No worries - sometimes public repos can be a headache - different coding styles, trust factor, etc. Anyway, thanks for your contributions to the Anki community - really appreciate it. Happy holidays.

---

<div class="post-metadata">

**Author:** ![OjisanSeiuchi](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/ojisanseiuchi/32/2578_2.png) [@OjisanSeiuchi](https://forums.ankiweb.net/u/OjisanSeiuchi)\
**Post date:** [January 3, 2022, 10:01pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/15 "2022-01-03T22:01:25Z")

</div>

There is a bug in rename.py line 106 - I’m sorry I didn’t capture the stack trace; but the fix looks straightforward. The return type of `mw.col.backend.find_and_replace()` is an `OpChangesWithCount` and to increment that change count, must access its `count` property, otherwise the increment assign operator fails. Here’s the entire method for `_replace_all_sound_src()`: Functioning correctly on macOS/Anki 2.1.48. [LATER] - I guess there’s a similar issue with the corresponding `img` method, too.

```auto
def _replace_all_sound_src(orig_name: str, new_name: str):
    "new_name doesn't have whitespace, dollar sign, nor double quote"
    
    old = f"[sound:{orig_name}"
    new = f"[sound:{new_name}"

    # Compatibility: 2.1.0+
    n = mw.col.findNotes("[sound")

    replaced_cnt = 0
    if anki_point_version >= 28:
        op_chg_cnt = mw.col.backend.find_and_replace(
            nids=n,
            search=old,
            replacement=new,
            regex=False,
            match_case=False,
            field_name=None,
        )
        replaced_cnt += op_chg_cnt.count
    else:
        replaced_cnt += findReplace(col=mw.col, nids=n, src=old, dst=new, regex=False, fold=False)
    return replaced_cnt

```

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [January 5, 2022, 4:54pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/16 "2022-01-05T16:54:04Z")

</div>

@OjisanSeiuchi : Thanks for another fix. I just uploaded a new version. I made a small change so that old anki versions still work and tried to adjust it to the rename image function as you suggested.

I re-added the most recent code of this add-on to github at [GitHub - ijgnd/anki21\_\_OpenInExternalEditor\_Rename\_Duplicate\_for\_Image\_Audio\_Video](https://github.com/ijgnd/anki21__OpenInExternalEditor_Rename_Duplicate_for_Image_Audio_Video) . This should make it easier for you if you have any more improvements.

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [December 13, 2022, 1:33pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/17 "2022-12-13T13:33:25Z")

</div>

there’s maybe a problem with renaming in 2.1.55

reported in another thread by @ferophila : [Is there an addon to reveal files in a file manger fom editor window? - #12 by ferophila](https://forums.ankiweb.net/t/is-there-an-addon-to-reveal-files-in-a-file-manger-fom-editor-window/25202/12)

To narrow it down I posted two questions:

- [Is there an addon to reveal files in a file manger fom editor window? - #13 by ijgnd](https://forums.ankiweb.net/t/is-there-an-addon-to-reveal-files-in-a-file-manger-fom-editor-window/25202/13)
- [Is there an addon to reveal files in a file manger fom editor window? - #14 by ijgnd](https://forums.ankiweb.net/t/is-there-an-addon-to-reveal-files-in-a-file-manger-fom-editor-window/25202/14)

Maybe it’s better to continue in this thread.

---

<div class="post-metadata">

**Author:** ![PulaArenaFighter](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/pulaarenafighter/32/11148_2.png) [@PulaArenaFighter](https://forums.ankiweb.net/u/PulaArenaFighter)\
**Post date:** [January 6, 2023, 9:46am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/18 "2023-01-06T09:46:23Z")

</div>

Is there a way to mass rename media files using as Input an Anki-field (e.g. sort field)?

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [January 10, 2023, 11:05am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/19 "2023-01-10T11:05:00Z")

</div>

not with my add-on. You could rename the files with a different tool e.g. using some regular expression and then update your notes in anki with the build-in search&replace feature that also supports regex. I’d certainly make a backup of all my files (and check that it’s complete) before trying this …

---

<div class="post-metadata">

**Author:** ![PulaArenaFighter](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/pulaarenafighter/32/11148_2.png) [@PulaArenaFighter](https://forums.ankiweb.net/u/PulaArenaFighter)\
**Post date:** [May 10, 2023, 8:12am UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/20 "2023-05-10T08:12:59Z")

</div>

Is it possible to have a custom development?  
How to contact you on this?  
I need to mass re-name audio files.  
The add-on should walk through an Anki-Card-Deck (Alternative: selected Anki-Notes in browser) and rename all sound-tags and it’s corresponding files of a selectable anki-destination-field (selection by configuration file)  
The new filename should be generated by a special Anki field calld “newfilename”.

Example: if the name of the sound tag and the corresponding filname is:  
[sound:hypertts-d9d4315dcdea8dda366681a0e62a7dae5aaa2a7d6752a4f1044493e0.mp3]  
and the content of the anki-field “newfilename” is  
“mynewfilename”, then it will be processed as follows:

1. new filename: mynewfilename.mp3
2. the sound tag of the anki-destination-field will be renamed to:  
[sound:mynewfilename.mp3]

P.S. Best would be a general solution that also works with pictures.

---

<div class="post-metadata">

**Author:** ![ijgnd](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@ijgnd](https://forums.ankiweb.net/u/ijgnd)\
**Post date:** [May 16, 2023, 12:40pm UTC](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555/21 "2023-05-16T12:40:59Z")

</div>

@PulaArenaFighter : Your suggestion sounds useful. But at the moment I don’t have time. There are some coders that offer to write custom add-ons. E.g. in the forum there’s @abdo who can be hired via [https://www.fiverr.com/abd\_nh](https://www.fiverr.com/abd_nh) . I don’t know him though I already merged some of his code into another add-on of mine that he was paid to make by a third party.

I guess the source code of your proposed add-on will have very little overlap with the source code of my add-on so that maybe it’s more future proof to make it into a standalone add-on.

[Next page](https://forums.ankiweb.net/t/open-in-external-editor-rename-duplicate-for-image-audio-video-official-thread/555.md?page=2)
