Yes, this can be done. Normally I would do such a file renaming with
Total Commander's Multi-Rename Tool which is incredible powerful, but extremly easy to use to rename thousands of files with a view mouse clicks within 20 seconds.
However, why should not the macro save the files with the preferred naming scheme when it is possible. So here is the solution.
First you have to create a new macro named
SaveChapterFile.
Attention: The name is case-sensitive.
And this macro must be saved in the same file as the other 2 macros or the merged macro. It is important that you first create this sub macro.
An additional macro is required because nesting of loops (loop inside another loop) is not possible in the macro environment. A inner loop is necessary to insert the corret number of leading zeros into the file name of the current chapter based on the number of digits of the last (=highest) chapter number.
As the name of the new sub macro already indicates, it creates the file name for the actual file and saves it.
Macro
SaveChapterFileTop
Clipboard 9
Paste
Paste
Key UP ARROW
Find RegExp "0+$"
Replace ""
Clipboard 8
Paste
Loop
Key UP ARROW
IfCharIs "0"
Key DOWN ARROW
Find Up "_"
Replace "_0"
Key END
Else
ExitLoop
EndIf
EndLoop
DeleteLine
Key END
".txt"
SelectToTop
Cut
EndSelect
Delete
SaveAs "^c"
CloseFile
Okay, after creating this macro, the code of the existing macro
Split2Chapters must be completely replaced with the following code:
InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
Find Up "^b"
EndSelect
Key LEFT ARROW
Key RIGHT ARROW
SelectWord
Clipboard 7
Copy
EndSelect
Top
Clipboard 9
Find RegExp "[a-z]*$"
Copy
EndSelect
Key END
Clipboard 8
CopyFilePath
NewFile
Clipboard 7
Paste
SelectToTop
Find RegExp "[0-9]"
Replace All SelectText "0"
Cut
EndSelect
Clipboard 8
Paste
Find Up "\"
Replace "\"
IfFound
DeleteToEndofLine
Else
"C:\"
EndIf
Clipboard 9
Paste
TrimTrailingSpaces
Bottom
"_"
Clipboard 7
Paste
ClearClipboard
Clipboard 9
InsertLine
SelectAll
Copy
CloseFile NoSave
Clipboard 8
Loop
Find "^b"
IfNotFound
ExitLoop
EndIf
Key RIGHT ARROW
Key LEFT ARROW
StartSelect
Find Select "^b"
IfSel
Key LEFT ARROW
Copy
EndSelect
Key RIGHT ARROW
Key LEFT ARROW
Else
EndSelect
Key RIGHT ARROW
Key LEFT ARROW
SelectToBottom
Copy
EndSelect
Key UP ARROW
Bottom
EndIf
NewFile
Paste
" "
StartSelect
Find RegExp Up Select "[~ ^t^p]"
Key RIGHT ARROW
Key RIGHT ARROW
Delete
EndSelect
Top
Find RegExp "[0-9]+"
Cut
"("
Paste
")"
PlayMacro 1 "SaveChapterFile"
EndLoop
ClearClipboard
Clipboard 9
ClearClipboard
Clipboard 0
In the main loop only the file name creating and file saving part is replaced now by the command PlayMacro because sub macro SaveChapterFile does this part now. Main changes are at top of this macro where the last chapter number is searched, then all digits of it are replaced with zeros to get the correct number of digits and those zeros are appended now to the file name after the underscore. There is no file extension anymore appended in this macro. This is done later in sub macro
SaveChapterFile. And the string in clipboard 9 with "path\book title_000" is now a real line with a line termination instead of only a string.
Macro
WordHtml2Text is not modified. If you again want to merge macro
WordHtml2Text with
Split2Chapters, you have again to delete last command (line) of
WordHtml2Text and the first 4 commands (lines) of
Split2Chapters.