# Rename files recursive by wildcard / regexp

**URL:** <https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600>\
**Category:** Help & Support\
**Tags:** feature-request\
**Created:** [June 3, 2026, 5:39am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600 "2026-06-03T05:39:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 5:39am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/1 "2026-06-03T05:39:18Z")

</div>

Maybe this is already in there somewhere, but I just want a simple feature that looks for all the \*.txt files in the current folder and recursive folders and rename them by regexp or just \*.txtBAK. I don't want to have to select each file, even though the flat view is handy for that.

A simple version of this this is easy in bash and looks like this:

find -iname "\*.txt" -exec mv '{}' '{}BAK' ;

---

<div class="post-metadata">

**Author:** ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)\
**Post date:** [June 3, 2026, 5:51am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/2 "2026-06-03T05:51:34Z")

</div>

Use the `RECURSE` argument:

```plaintext
Rename FROM=*.txt TO=*.txtBAK RECURSE

```

[Rename](https://docs.dopus.com/doku.php?id=reference:command_reference:internal_commands:rename)

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 7:44am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/3 "2026-06-03T07:44:47Z")

</div>

But if I don't choose a file the Rename button is disabled, and if I choose a file it seems to work on only that file. I'm confused. I thought that the preview pane should show what it files it is going to rename but it doesn't when using wildcards like '\*.txt'.

---

<div class="post-metadata">

**Author:** ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)\
**Post date:** [June 3, 2026, 8:45am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/4 "2026-06-03T08:45:23Z")

</div>

If you want this to work on selected folders instead of the source, use

```plaintext
Rename FROM={filepath}*.txt TO=*.txtBAK RECURSE

```

If you want the preview, add `ADVANCED`:

```plaintext
Rename FROM={filepath}*.txt TO=*.txtBAK RECURSE ADVANCED

```

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 9:01am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/5 "2026-06-03T09:01:15Z")

</div>

I right click on the toolbar and choose Customize, then right click the Rename button and choose edit. If I add what you suggested the rename doesn't do anything, no error, just nothing. Am I digging too deep here maybe 🙂 ? What I'm trying to do is exactly what the bash command above shows, it's very simple.

So the original there is:  
@disablenosel  
@nodeselect

=return("Rename " + ($glob:dopus\_Rename\_Simple ? "SIMPLE" : "ADVANCED"))

Are you talking about somewhere else to add what you just wrote?

---

<div class="post-metadata">

**Author:** ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)\
**Post date:** [June 3, 2026, 9:08am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/6 "2026-06-03T09:08:00Z")

</div>

I'd make a new button. Here's mine:

> **XML**
>
> ```plaintext
> <?xml version="1.0"?>
> <button backcol="none" display="both" label_pos="right" textcol="none">
> <label>59600</label>
> <icon1>#newcommand</icon1>
> <function type="normal">
> <instruction>// Rename FROM=*.txt TO=*.txtBAK RECURSE</instruction>
> <instruction>Rename FROM={filepath}*.txt TO=*.txtBAK RECURSE ADVANCED</instruction>
> </function>
> </button>
> 
> ```

[How to use buttons and scripts from this forum](https://resource.dopus.com/t/how-to-use-buttons-and-scripts-from-this-forum/3546)

---

<div class="post-metadata">

**Author:** ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)\
**Post date:** [June 3, 2026, 9:12am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/7 "2026-06-03T09:12:42Z")

</div>

> [@lxp](#):
>
> `Rename FROM={filepath}*.txt TO=*.txtBAK RECURSE`

Since the filepath is provided, the `RECURSE` option has no effect: from a quick test, this is not operating on the `.txt` files in subfolders.

The initial `Rename FROM=*.txt TO=*.txtBAK RECURSE` works ... but requires (at least here) that something is selected in the sourcepath, otherwise the button is not active (even if there is no `@disablenosel`).

EDIT: Can't reproduce anymore the need to have something selected.

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 9:15am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/8 "2026-06-03T09:15:54Z")

</div>

Where are you typing that code? In the Macro field of the Rename popup window?

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 9:19am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/9 "2026-06-03T09:19:30Z")

</div>

I'm not trying to do anything dramatic or complex here, just stand in a folder and pick up, recursively, all \*.txt files and rename them to \*.txtBAK. And I would hope to make this with other renames without having to write a separate script or/and button.

---

<div class="post-metadata">

**Author:** ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)\
**Post date:** [June 3, 2026, 9:21am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/10 "2026-06-03T09:21:29Z")

</div>

This code goes directly in a button. This is what prevents you from using the Rename dialog.  
You can call a Rename action without having to open the dialog if the action is properly defined in your call.

The XML code provided by lxp can be copied in the clipboard and pasted in a toolbar when in "Customize mode" (as described in the link provided below the xml code). This will create a button.

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 9:25am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/11 "2026-06-03T09:25:05Z")

</div>

It starts to feel like a feature request, if I choose a folder in the File Explorer side without choosing any file and click rename, it should just start from there and find all the files using wildcards or regexp and rename them. And if I check the box "Rename in subfolders" it should just do that.

And I like generic solutions, not a script per purpose. Total Commander does this nicely with regexp, even though a bit complicated it works really well.

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [June 3, 2026, 9:56am UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/12 "2026-06-03T09:56:45Z")

</div>

> [@How to use buttons and scripts from this forum](https://resource.dopus.com/t/how-to-use-buttons-and-scripts-from-this-forum/3546/1):
>
> This post explains how to add buttons to toolbars and menus, and also applies to raw commands for things like standalone hotkeys. For how to use Script Add-Ins, please scroll down to the post below this one. See Also: The manual has more detail in…

---

<div class="post-metadata">

**Author:** ![MegMac](https://resource.dopus.com/user_avatar/resource.dopus.com/megmac/32/51564_2.png) [@MegMac](https://resource.dopus.com/u/MegMac)\
**Post date:** [June 3, 2026, 1:50pm UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/13 "2026-06-03T13:50:57Z")

</div>

I do this type of think often without a script /command.

- I select the parent folder and open it in Flat View (Mixed) No folders.
- Then I use the Filter bar to select the file extension. In your case, the .txt extension.
- I select the files displayed.
- I open the Rename dialog.
- Then I use whatever Rename option, like Regex, suits how I want to rename.

---

<div class="post-metadata">

**Author:** ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)\
**Post date:** [June 3, 2026, 2:40pm UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/14 "2026-06-03T14:40:32Z")

</div>

I think OP knows this can be done that way, see. :

> [@qai](#):
>
> I don't want to have to select each file, even though the flat view is handy for that.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [June 3, 2026, 2:45pm UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/15 "2026-06-03T14:45:55Z")

</div>

You can also go up a level, select the directory, click Rename and turn on **Rename files in selected sub-folders**.

---

<div class="post-metadata">

**Author:** ![MegMac](https://resource.dopus.com/user_avatar/resource.dopus.com/megmac/32/51564_2.png) [@MegMac](https://resource.dopus.com/u/MegMac)\
**Post date:** [June 3, 2026, 2:50pm UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/16 "2026-06-03T14:50:51Z")

</div>

Yes, but he may not have known about the Filter Bar, which is not in the Default Configuration, as they seems to be a new user.

I often add detail to help other people with a similar question.

---

<div class="post-metadata">

**Author:** ![qai](https://resource.dopus.com/letter_avatar_proxy/v4/letter/q/c0e974/32.png) [@qai](https://resource.dopus.com/u/qai)\
**Post date:** [June 3, 2026, 5:27pm UTC](https://resource.dopus.com/t/rename-files-recursive-by-wildcard-regexp/59600/17 "2026-06-03T17:27:12Z")

</div>

I just want to say that Directory Opus is by far the best file manager/explorer I've ever seen. I'm kind of nitpicking with this. Keep up the good job, and I will read the documentation.

I have one nut to crack though, where do I find the error output in a case where I click on a button and nothing happens?
