# TrId2 File type detector: dialog and "fix file extension" command

**URL:** <https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959>\
**Category:** Buttons/Scripts\
**Tags:** script, jscript\
**Created:** [July 10, 2026, 8:33pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959 "2026-07-10T20:33:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PolarGoose](https://resource.dopus.com/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@PolarGoose](https://resource.dopus.com/u/PolarGoose)\
**Post date:** [July 10, 2026, 8:33pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/1 "2026-07-10T20:33:35Z")

</div>

This plugin uses the TrId2 library to detect file types based on file content.  
This plugin provides a dialog that shows the file type information and a "fix file extension" command.

 ![dialog_screenshot](https://resource.dopus.com/uploads/default/original/3X/5/6/56fbab2217881b6164e1a5830a2450d4305b4df1.png)

Please refer to the Readme in the [GitHub repo](https://github.com/PolarGoose/DirectoryOpus-TrId2FileTypeDetector-dialog-and-commands) on how to use it.

---

<div class="post-metadata">

**Author:** ![PolarGoose](https://resource.dopus.com/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@PolarGoose](https://resource.dopus.com/u/PolarGoose)\
**Post date:** [July 12, 2026, 10:42am UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/2 "2026-07-12T10:42:22Z")

</div>

I have added extra file information:

- MimeType from Unix File (libmagic)
- Encoding from UcharDet

Now the dialog works with text files as well.

---

<div class="post-metadata">

**Author:** ![PYCHBI](https://resource.dopus.com/user_avatar/resource.dopus.com/pychbi/32/64658_2.png) [@PYCHBI](https://resource.dopus.com/u/PYCHBI)\
**Post date:** [August 31, 2026, 2:14am UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/3 "2026-08-31T02:14:56Z")

</div>

Hi  
I noticed that the percentage after Probability uses a comma ( , ) as the separator, for example, `37,1%`. I suggest making it display with a decimal point instead.

---

<div class="post-metadata">

**Author:** ![a815](https://resource.dopus.com/letter_avatar_proxy/v4/letter/a/cdc98d/32.png) [@a815](https://resource.dopus.com/u/a815)\
**Post date:** [August 31, 2026, 3:13am UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/4 "2026-08-31T03:13:14Z")

</div>

Just remove `.replace(".", ",")` from the script.

> <https://github.com/PolarGoose/DirectoryOpus-TrId2FileTypeDetector-dialog-and-commands/blob/2c60c4e7b1f97a601906ea4b33add4214d716eab/scr/DirectoryOpus-TrId2FileTypeDetector-dialog-and-commands.js#L103>

```js
addItemToListView(listView, "Probability", trId2Candidates[i].Probability.toFixed(1) + "%", /* bold */ false)

```

Or a better way: use `toLocaleString()` to follow the system's locale format:

```js
addItemToListView(listView, "Probability", trId2Candidates[i].Probability.toLocaleString() + "%", /* bold */ false)

```

---

<div class="post-metadata">

**Author:** ![BXL](https://resource.dopus.com/user_avatar/resource.dopus.com/bxl/32/70791_2.png) [@BXL](https://resource.dopus.com/u/BXL)\
**Post date:** [November 2, 2026, 4:42pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/5 "2026-11-02T16:42:45Z")

</div>

I currently have the following 'fix file extension' button command that works perfectly, but only on a single file at once:

```auto
@noprogress
TrId2FileTypeDetector_FixFileExtension FILE {filepath}
```

Is there a way to apply the command to all the files within a specific folder or a selection of multiple files with one button click?

---

<div class="post-metadata">

**Author:** ![PolarGoose](https://resource.dopus.com/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@PolarGoose](https://resource.dopus.com/u/PolarGoose)\
**Post date:** [November 2, 2026, 6:19pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/6 "2026-11-02T18:19:20Z")

</div>

I have released a new version: `v3.0`

@PYCHBI,

Your issue is fixed.

@BXL,

This command now applies to all selected files. Folders are ignored.

---

<div class="post-metadata">

**Author:** ![BXL](https://resource.dopus.com/user_avatar/resource.dopus.com/bxl/32/70791_2.png) [@BXL](https://resource.dopus.com/u/BXL)\
**Post date:** [November 2, 2026, 7:29pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/7 "2026-11-02T19:29:49Z")

</div>

@PolarGoose Wow, that was super quick. Just what I was looking for. Thank you very much! 😃

(I previously used the TrID/32 - File Identifier v2.24 - (C) 2003-16 by M. Pontello, but I prefer your script as it feels quicker and snappier and doesn't pop a command prompt window).

Thank again! 🙂

---

<div class="post-metadata">

**Author:** ![PolarGoose](https://resource.dopus.com/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@PolarGoose](https://resource.dopus.com/u/PolarGoose)\
**Post date:** [November 2, 2026, 8:17pm UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/8 "2026-11-02T20:17:04Z")

</div>

> [@BXL](#):
>
> that was super quick

Thanks. You made your request during my hobby project work time.

> I prefer your script as it feels quicker and snappier and doesn't pop a command prompt window

Yes, it is much faster because the file type database loads only once during DOpus startup. This is also why I added to the GUI dialog Unix file utility and Uchardet output, because their databases are loaded during startup as well and thus the detection is very fast.

---

<div class="post-metadata">

**Author:** ![jinsight](https://resource.dopus.com/user_avatar/resource.dopus.com/jinsight/32/43666_2.png) [@jinsight](https://resource.dopus.com/u/jinsight)\
**Post date:** [November 3, 2026, 2:49am UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/10 "2026-11-03T02:49:23Z")

</div>

Can anyone suggest why I only get a single file in the GUI dialog even when selecting multiple different files?

The "fix file extension" command does work for multiple selected files.

---

<div class="post-metadata">

**Author:** ![PolarGoose](https://resource.dopus.com/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@PolarGoose](https://resource.dopus.com/u/PolarGoose)\
**Post date:** [November 3, 2026, 6:53am UTC](https://resource.dopus.com/t/trid2-file-type-detector-dialog-and-fix-file-extension-command/59959/11 "2026-11-03T06:53:54Z")

</div>

> [@jinsight](#):
>
> Can anyone suggest why I only get a single file in the GUI dialog even when selecting multiple different files?

The GUI dialog works only for a single file.
