# Change file extension

**URL:** <https://community.wolfram.com/t/change-file-extension/20748>\
**Category:** Questions\
**Tags:** import-and-export\
**Created:** [September 23, 2022, 6:03am UTC](https://community.wolfram.com/t/change-file-extension/20748 "2022-09-23T06:03:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunovusini](https://avatars.discourse-cdn.com/v4/letter/b/a9a28c/32.png) [@brunovusini](https://community.wolfram.com/u/brunovusini)\
**Post date:** [September 23, 2022, 6:03am UTC](https://community.wolfram.com/t/change-file-extension/20748/1 "2022-09-23T06:03:12Z")

</div>

Dear All,  
I have to open two files that have the same name, but different extension.  
In the same directory I have one binary file (i.e test.bin) and one text file (i.e. test.txt).  
I use this string to open the bin file

```
NAME = SystemDialogInput["FileOpen"];

```

Now Name is C://path//test.bin

Is there the possibility to define in an automatic way

```
NAME2=C://path//test.txt

```

Thank you very much and best regards

---

<div class="post-metadata">

**Author:** ![brunovusini](https://avatars.discourse-cdn.com/v4/letter/b/a9a28c/32.png) [@brunovusini](https://community.wolfram.com/u/brunovusini)\
**Post date:** [September 23, 2022, 12:19pm UTC](https://community.wolfram.com/t/change-file-extension/20748/2 "2022-09-23T12:19:35Z")

</div>

Dear all,  
I found the solution by myself. I used this construct:

```
NAME2 = FileNameJoin[{DirectoryName[NAME], 
    F = FileBaseName[NAME] <> ".txt"}];

```

Maybe it can help. Best regards.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [September 23, 2022, 1:40pm UTC](https://community.wolfram.com/t/change-file-extension/20748/3 "2022-09-23T13:40:31Z")

</div>

Assuming those are the only two files in that directory with the name “test”

```
{name1, name2} = Filenames["test.*", "C://path"]

```

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [September 23, 2022, 7:37pm UTC](https://community.wolfram.com/t/change-file-extension/20748/4 "2022-09-23T19:37:07Z")

</div>

Bruno,

here is one handy way to select txt-files using `SystemDialogInput`:

```
(* specific directory, e.g. home directory: *)
dir = $HomeDirectory;
filename=SystemDialogInput["FileOpen", {dir, {"Text-Data" -> {"*.txt"}, "Simply Everything" -> {"*"}}}]

```
