I'm trying to create a simple file merge tool to combine split log file in to a text file.
FileSelectFolder, folder, \\Myserver\Data\
InputBox, filename, Save File,Please type the name you will call the merged file.`n The file will be saved in the folder "merged" of the same root directory as its "part files" are located., , , , , , , ,merged_file.txt
if errorlevel = 1
MsgBox, 4, File Overwrite -or- Append?, The file already exists. Do you want to append to this file? `nNote: If you select "No" the existing file will be replaced during this process.
Runwait, %COMSPEC% /c copy /k %folder%\*.log %folder%\merged\%filename%
I did not want to use AHK fileread and fileappend as log file are quite big ~40mb.
The above code does not yield any errors but does not produce any file either.
I tried adding " to the parameters with no success.
It's really easy actually:
Loop, Read, C:\FileToReadFrom.txt, C:\FileToAddTo.txt FileAppend, `r`n%A_LoopReadLine%
This way you only load one line at a time into the RAM.
If you want to know more:
Loop, Read file contents
Okay one more shot here!
As it turns out you do need to quote your Path in command string for use with COMSPEC.
I also correctly stated earlier that there is no /K switch or option for the Copy command. There is Compsec switch /K which Keeps the Terminal Open and a /c which means Close Terminal.
Also your syntax is wrong with Copy. In order to Concatenate a file with Copy you need to do something like this:
Copy mergedfile.txt+file2merge.txt newmergedfile.txt
But I suggest you use Type to Concatenate a text file instead:
RunWait, %COMSPEC% /c type "%folder%\*.log" >> "%folder%\merged\%filename%"