The Windows copy command joins every daily HMI log file in a folder into one text file in a single pass. Match the column layouts first, keep the output name out of the wildcard set, then import once into Excel and keep the original daily files.
An HMI that starts a new trend log every day turns a six-month history into a folder of 180 fragments. Nobody wants to paste that into Excel one file at a time. One built-in Windows command does the whole job: copy *.txt all.txt joins every log file in the folder into a single text file in one pass. The daily files stay untouched, and the merged file imports into Excel once. The command only joins records. It never sorts by time, reconciles different column layouts, or repairs a half-written file, so the few minutes of checking below decide whether the merged file is usable.
What you need
- The daily log files, copied off the panel's USB stick or network share into a working folder on the PC. Work on copies; the originals are your recovery set.
- A Windows PC with Command Prompt.
- Notepad or another plain text editor.
- Excel, or any spreadsheet, for the import at the end.
If the panel warns that its log memory is full while you collect, clear that first; fixing HMI log buffer memory full errors on one screen is a separate job, and merging files from a buffer that is already dropping records only preserves the gaps.
Check the files before you merge
Open one file from the start of the period, one from the middle and one from the end in the text editor. Three checks:
- Same columns, same order, in all three files: date and time in the first column, then the logged values. Files from one trend or log setup merge cleanly; files whose column count or labels differ belong to different trend setups and must be merged as separate sets.
- One header row at the top of every file, or none anywhere. Headers in some files only mean the header output was switched on and off during the period, and the repeat headers need stripping after the merge.
- The same extension on every file. Run
dir *.txtin the folder and compare the count with what the period should produce; a mixed set of extensions means two merges or renamed copies.
Pick the output name now. Keep the output folder separate from the input folder, or give the output a name no daily file can match, so a rerun cannot fold an old merge back into itself.
Run the merge command
- Copy the daily files into a working folder on the PC, for example C:\Logs\March. Leave the stick or share untouched; the same habit as backing up HMI recipe files before a project download applies here: the backup exists before you touch anything.
- Open Command Prompt: press the Windows key, type
cmd, press Enter. - Type
cdfollowed by the working folder path and press Enter.help cdprints the syntax if the path has spaces. - Run
dir *.txtand confirm noall.txtis listed. - Run
copy *.txt all.txt. Windows answers1 file(s) copied, and a merge of a few hundred files takes seconds. - Type
exitto close the window.
The panel keeps writing its own daily files while you do this; nothing on the machine changes.
Example: 180 daily files logged once a minute
Inputs: 180 daily files, one per day, the six-month period you staged in the working folder; one sample every 60 seconds, the log interval set on the panel; 86,400 seconds in a day; one header row per file with header output on; Excel's worksheet limit of 1,048,576 rows, in place since the Excel 2007 release.
The rule in words: rows in the merged file equals the number of files times the samples per day, plus one header row per file, where samples per day is 86,400 divided by the interval in seconds.
The arithmetic:
- 86,400 ÷ 60 = 1,440 rows per file
- 180 × 1,440 = 259,200 data rows
- 259,200 + 180 = 259,380 rows in the merged file
- 1,048,576 − 259,380 = 789,196 rows to spare
Result: all 180 files fit in one worksheet with room to spare. Merge the whole six months in one pass and import once.
The decision, with its threshold: each merged file holds 1,441 rows per day of logging (1,440 data rows plus one header), so the ceiling works out to roughly 727 days per file at 1,048,576 rows (1,048,576 ÷ 1,441 ≈ 727). A year or two of one-minute logs merges into one worksheet. Three years does not: 1,095 days × 1,441 = 1,577,895 rows, so split the merge by year. The interval moves that ceiling hard. At one sample every 5 seconds a day is 86,400 ÷ 5 = 17,280 rows, the ceiling drops to 60 days (60 × 17,280 + 60 = 1,036,860, just under the limit), and 63 days at 1,088,640 rows would overflow, so at that rate split the merge by month.
Check the merged file
Open all.txt in the text editor before anything touches Excel.
- The first record carries the earliest date you staged and the last record the latest. Either one missing means the staging folder was incomplete; compare the file count against
dir. - Search for the header text. With headers on, it appears once per source file: 180 files, 180 header lines. More than that and an old merge got folded in.
- Read one day boundary: the last rows of one date, then the first rows of the next, with the column count unchanged.
If a check fails, fix the staging folder and rerun the command. The daily files were never modified, so rebuilding costs nothing but the seconds the command takes.
Import into Excel once
Start Excel's text import (the Text Import wizard or the Get Data from text option, depending on the version) and point it at all.txt. Set the delimiter to the one the logs use, comma for CSV-format logs, and set the date and time column to text so the stamp stays in one field. A stamp split into a date fragment and a time fragment in separate columns is the most common import failure; redoing the import with that column as text fixes it. Then compare three rows in the sheet against the same records in Notepad: the first record, the last record and one from a day boundary. Sort by the date and time column, filter to the period you report on, and save the sheet as an .xlsx working copy. Keep all.txt and the daily files; the spreadsheet is the throwaway.
When the plain merge is not enough
The command is a one-off tool. If the column layouts changed during the period, merge each layout as its own set and map the columns deliberately. If the logs feed a recurring report or a dashboard, the merge belongs in that system's export step, not in a command you run by hand. And if the analysis only ever needs shift summaries, check whether the panel's logging interval can be relaxed, because fewer rows mean more history per worksheet.
Recommendation: merge daily HMI logs with copy *.txt all.txt when the files share one column layout, the output folder is separate from the input folder, and the merged row count stays under Excel's 1,048,576-row worksheet limit; open files and copy rows by hand only for a handful of days or a one-off look at a single shift.
Questions
What if the daily logs use a .csv extension?
Run the same command with that extension: copy *.csv all.csv. The wildcard picks up whatever extension the panel actually writes, so confirm it in the folder first. If the folder holds both .txt and .csv files, one wildcard covers only its own set; merge each set on its own, or rename the copies in the working folder so a single wildcard catches everything.
Why does the merged file double when I run the command twice?
The previous all.txt was still in the folder, so the wildcard matched it as an input and the command wrote the old merge back into itself; Windows may stop with a message that a file cannot be copied onto itself. Move or delete the old output before rerunning, or keep the output in its own folder. The daily source files are untouched, so rebuilding the merge from them is always clean.
A separate merge utility reported it was unable to write a file. What now?
That error points at the destination, not at the log data. The usual causes are an output folder the utility cannot write to, or the output file still open in Excel or an editor. Retry with the output pointed at a simple local folder such as C:\Logs\merged, and close any program holding the output file. The built-in copy command avoids the third-party tool altogether.
How do I get the merged records into date order?
If the file names carry the date with the year first, such as 20260304, the merged records come out oldest to newest without any sorting. With any other naming, sort by the date and time column in Excel after import. Confirm the first and last records in the text editor either way before you graph anything.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.