RENAME command for files in subfolder

(For the record, I looked at a dozen+ forum threads that looked like they might have been helpful based on their titles, but no such luck.)

I have a custom command which creates one or more new folders, with names based on selected filenames, in the current SOURCE folder, then uses a third-party SPLIT command (from GNU Core Utilities) to split selected large files only at existing lines and deposit the pieces in the respective new folders. For example, if I currently have files named “Test1.log” and “Test2.log” selected, my command will create folders named “” and “”, then split the two files into pieces in the appropriate subfolder. The SPLIT command I use creates files named “Test1.log.00000”, “Test1.log.00001” etc. I’d actually like the resulting files to have .txt filename extensions (i.e. “Test1.log.00000.txt”), but the GNU Core Split command doesn’t appear to have any options for naming them that way. That being the case, I’m hoping to follow up the SPLIT command with a DOpus Rename command that does the trick, but can’t seem to get it working. I’ve tried all of the following:

Rename FROM "\*.*" REGEXP FINDREP PATTERN "\.log\.(\d{5})" TO ".log.\1.txt"

Rename FROM "\Test1.log.*" REGEXP FINDREP PATTERN "\.log\.(\d{5})" TO ".log.\1.txt"

Rename FROM "T:\\*.*" REGEXP FINDREP PATTERN "\.log\.(\d{5})" TO ".log.\1.txt"

Rename REGEXP PATTERN "(Test1\.log\.parts\\.+\.log\.\d{5})" TO "\1.txt"

What am I missing?

This would add a .txt extension to all *.log.<5 digits> file below each selected diretory:

Rename REGEXP PATTERN="^(.*\.log\.\d{5})$" TO="\1.txt" RECURSE


  • If you select a file that matches the pattern, it'll also be renamed.

  • Anything below the folder matching the pattern will be renamed, including in sub-folders of the folder. In other words, it won't stop at the first child level.


I’m afraid that doesn’t do anything here, even if I’m already in the subdirectory where the files to be renamed reside. I’ve tried it both ways (in parent directory, and in directory with files) via custom command from menu, and via > directly in lister. Nothing. But I really want to target only the contents of the specific subdirectory (or subdirectories) corresponding to the selected files anyway. Apart from the lingering mystery of why neither your method nor any of the previous ones I tried worked, I did end up getting the following to do what I wanted, based on help from lxp in the thread “Rename PATTERN TO REGEXP with filename-passing codes” that I started last July (thanks again, @lxp!):

Rename FROM="{filepath$}.parts\*" PATTERN="({file$}\.part\.\d{5})" TO="\1.txt" REGEXP

It worked in my testing. You needed to select the folders you wanted to rename things in, FWIW.

Ah. I should have seen that, since you weren’t using FROM. I also see that I should have been more explicit about what I was trying to do in my first post. When I wrote “I’m hoping to follow up the SPLIT command with a DOpus Rename command that does the trick”, I meant that I want the rename operation to come after the split operation, as part of the full sequence in the same custom command. In other words, with one or more files selected, I want one custom command to do all of:

  1. Create one subfolder named “<filename.ext>.parts” for each file selected.

  2. Split each selected file into multiple parts and put them in the corresponding subfolder that was just created.

  3. Rename all the files (ending in “.00000”, “.00001”, etc.) in those newly created and populated subfolders so that “.txt” is tacked onto their existing names.

When I run this command, the subfolders will not yet exist, so they can’t be selected — though I guess I could theoretically put code into the custom command to select them prior to the rename code.

But anyway, I’ve apparently declared success with my code prematurely. The code I wrote was working for me in my last post evidently fails to work under some circumstances. It successfully renames these:

(With file “Test1.log” selected)
“\Test1.log.part.XXXXX” to “\Test1.log.part.XXXXX.txt”
“Test\Test 1.log.part.XXXXX” to “Test\Test 1.log.part.XXXXX.txt”

It DOES NOT rename these:

(With file “Lastname, Firstname - [1999-99] Some Title - Paperwork.log” selected)
“Lastname, Firstname - [1999-99] Some Title -\Lastname, Firstname - [1999-99] Some Title - Paperwork.log.part.XXXXX”

Tried so far without success:

Rename FROM="{filepath$}.parts\*" PATTERN="({file$}\.part\.\d{5})" TO="\1.txt" REGEXP
Rename FROM="{filepath$}.parts\*" PATTERN="(\.part\.\d{5})" TO="\1.txt" REGEXP FINDREP
Rename FROM="{filepath$}.parts\*.*" PATTERN="(\.\d{5})$" TO="\1.txt" REGEXP FINDREP IGNOREEXT

Hopefully someone sees something that’s eluding me.

Skip all the regex stuff and just use PATTERN=* TO=*.txt.

Well, you’re right, of course — thanks again for that, it hadn’t occurred to me — though it still isn’t my preferred solution. My inclination is to be as specific as possible in pattern matching, even if something simpler and more vague will do the trick right now, for the sake of future-proofing my code as much as possible — in case, for example, I see merit at some point in having this same custom DOpus command put some other files that I DON’T want to rename into the new folders along with the ones to be renamed.

I finally realized what I was missing from my closest preferred code:

Rename FROM="{filepath$}.parts\*" PATTERN="({file$|escregexp}\.part\.\d{5})" TO="\1.txt" REGEXP

But even though the other ways I had tried it didn’t meet my preferred expectations for specificity, I’m still wracking my brain trying to figure out why these didn’t work:

Rename FROM="{filepath$}.parts\*" PATTERN="(\.part\.\d{5})" TO="\1.txt" REGEXP FINDREP
Rename FROM="{filepath$}.parts\*" PATTERN="(\.\d{5})$" TO="\1.txt" REGEXP FINDREP

Am I overlooking something (wouldn’t be the first time, of course), or is it a bug in DOpus’ RegEx engine?

Try FINDREP=ext.

Tried both of these:

Rename FROM="{filepath$}.parts\*" FINDREP=ext PATTERN="(\.part\.\d{5})$" TO="\1.txt" REGEXP
Rename FROM="{filepath$}.parts\*" FINDREP=ext PATTERN="(\.\d{5})$" TO="\1.txt" REGEXP

Both worked — mystery (partly) solved, and thanks once again. The remaining mystery, which will probably need Jon or Leo to weigh in, is why FINDREP doesn’t simply obey the inclusion or non-inclusion of IGNOREEXT.

FINDREP existed a long time before IGNOREEXT and NOIGNOREEXT, which may be why it's different.

Oh, ok. Thanks for the explanation. I think this is another part of the help file that needs additional clarification, though. Something along the lines of IGNOREEXT/NOIGNOREEXT, or absence of them, having no effect on FINDREP, for which users should instead use FINDREP=ext as necessary.