cm_Combine, merge file command, hope to improve and add some parameters

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 87
Joined: 2024-11-03, 02:45 UTC

cm_Combine, merge file command, hope to improve and add some parameters

Post by *xxxdo1 »

The help document says that before using the cm_Combine command, the files must be renamed in ascending order to be detected and merged into one file.

This is a very cumbersome step with some disadvantages. I can't select files from the two panels to merge them, nor can I use cm_DirBranch to expand multiple directories and then select files to merge them.
Improvement suggestions:

Select multiple text files directly in the panel list, and then run cm_Combine to merge them directly

Below, I used bat to replicate the cm_Combine command.
For example:

Code: Select all

[em_MergeFiles]
cmd=MergeFiles.bat
param="%T" %P%S
Contents of MergeFiles.bat

Code: Select all

@echo off

shift
set "path=%~0"

if exist "%path%" (
    pushd "%path%" >nul 2>&1
    if errorlevel 1 (echo Path is not a directory: %path% & pause>nul & exit)
    popd >nul
) else (echo Path does not exist: %path% & pause>nul & exit)

set "F=.txt .reg .bat .ini"
set "E=%~x1"

if "%E%" equ "" (set "E=.txt")
for %%i in (%F%) do (
    if "%E%" equ "%%i" (set "a=1" & break)
)
if "%a%" neq "1" (set "E=.txt")

set "T=%path%new_%TIME:~3,2%%E%"
:loop
    shift
    if "%~0" equ "" (exit)
    if "%~x0" equ "" (goto loop)
    for %%i in (%F%) do (
        if "%~x0" equ "%%i" (type "%~0" >> "%T%" & break)
    )
goto loop
The em_MergeFiles is very simple, just as an example to describe my idea.
Suggestions:
  • Remove the prerequisite that the files must be in ascending order, so that I can select files from both panels to merge them, or use the cm_DirBranch command to expand multiple directories and then select files to merge them.
  • Add some parameters:
    • /T: output path after merging files.
    • /E: output extension.
    • /F: filter, some file extensions are selected by mistake, automatically ignored.
    • /G: Quiet mode, start merging files immediately.
  • In MergeFiles.bat above, I have implemented these parameters. :D
Merging files is a very high-frequency command. I often export registry values ​​from different paths and merge multiple registry values ​​into one file. I hope that the cm_Combine step in the next version will be simpler and more efficient.

Merge files. Is there any other more efficient script method now?
Post Reply