I wanted to concatenate all my MBAM (Malwarebytes) text Log files into a single text file, with a view to using the latter as a database that I could search and analyse in some way (maybe as input to a spreadsheet or DB tool).STEPS:
- 1. Set up a SCRAP working directory.
- 2. Copy all MBAM Log files from their folder into the SCRAP folder - there were 87 files, ranging from mbam-log-2010-12-28 (23-38-53).txt to mbam-log-2013-04-17 (04-38-12).txt.
- 3. Mass renamed the 87 log files to the form xnn.txt (where nn = 01 to 87).
- 4. Concatenated all 87 filenames into one long string with a "+" sign between each filename - e.g. x01.txt+x02.txt+…
- 5. Turned this string into a DOS COPY command: copy [string] /A concatALL.txt /A
- 6. Ran the COPY command.
- 7. Examined the output file concatALL.txt
Examination of the output file concatALL.txt
showed that it was fine up until somewhere before the middle of the file, when the text became weird-looking with embedded spaces, right after the end of the content from file 34
Further inspection of the source files showed that:
- files 01-34 had been encoded in Windows 1252 Western European.
- files 35-87 had been encoded in Unicode, UTF-16 little endian.
- I concatenated files 01-34 into file concat01.txt
- I concatenated files 35-87 into file concat02.txt
The latter two files each seemed to read fine in a text editor. It was only when you tried to concatenate them that problems arose.
I then copied/pasted all the text in file concat02.txt
onto the end of concat01.txt
, then saved and closed the concat01.txt
file. Opening it subsequently, the text read fine all the way through. Problem solved.My question is: What approach could have enabled me to do this quicker, or with more automation?