Join text files into one file

Post comments and suggestions for RoboTask here
Post Reply
vbigdeli
Posts: 34
Joined: Mon Sep 15, 2008 2:53 am

Join text files into one file

Post by vbigdeli »

I need a plugin to join multiple text files in one directory and join/append them into one file.


I could do it with write text file but it takes alot of time because I had more than 3k text files and the final file would become more than 500MB .
So I need append text file plugin not the write text files which write files from the beginning.

I already used txtcollector software to do it.

I hope to see my suggestions soon or otherwise I have to move to WinAutomation .

Thanks Oleg.
Oleg
Site Admin
Posts: 3011
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Join text files into one file

Post by Oleg »

I added your suggestion into our ToDo. We'll discuss it.

But pay attention that you can join text files in a folder right now
See the example below:

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1170"
Hide=INTEGER|0
ID=INTEGER|1270824523
LogOnAsUser=INTEGER|1
Name=STRING|"Join TXT file in folder to one file"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TARGETFILE"" with value ""d:\dest\target.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TARGETFILE"
varvalue=STRING|"d:\dest\target.txt"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""SOURCEDIR"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SOURCEDIR"
varvalue=STRING|"c:\incoming"

[Actions\Action3]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|-1
Name=STRING|"Delete File"
Params=FOLDER

[Actions\Action3\Params]
Count=STRING|"1"
deletedirs=STRING|"0"
file0=STRING|"{TargetFile}"
hidden=STRING|"1"
subdir=STRING|"0"
system=STRING|"1"
ToRecycleBin=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CNT"" with value ""1"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CNT"
varvalue=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action5\Params]
createmode=STRING|"1"
date1=STRING|"20150109"
date2=STRING|"20150109"
destvar=STRING|"CURRENTFILE"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{SourceDir}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action6]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action6\Params]
message=STRING|"{cnt}; {CurrentFile}"
type=STRING|"3"

[Actions\Action7]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TargetFile}"
Params=FOLDER

[Actions\Action7\Params]
encode=STRING|"0"
fileexists=STRING|"1"
filname=STRING|"{TargetFile}"
line0=STRING|"*******************"
line1=STRING|"File: {CurrentFile}"
line2=STRING|"*******************"
line3=STRING|"{TextFile({CurrentFile})}"
linecount=STRING|"4"
suppress=STRING|"0"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""cnt"""
Params=FOLDER

[Actions\Action8\Params]
incement=STRING|"1"
vaiable=STRING|"cnt"

[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

Also see another version of this task. It should work faster

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1206"
Hide=INTEGER|0
ID=INTEGER|18567467
LogOnAsUser=INTEGER|1
Name=STRING|"Join TXT file in folder to one file (version 2)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TARGETFILE"" with value ""d:\dest\target.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TARGETFILE"
varvalue=STRING|"d:\dest\target.txt"

[Actions\Action10]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action11]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action11\Params]
message=STRING|"Writing target file"
type=STRING|"3"

[Actions\Action12]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TargetFile}"
Params=FOLDER

[Actions\Action12\Params]
encode=STRING|"0"
fileexists=STRING|"1"
filname=STRING|"{TargetFile}"
line0=STRING|"{Text}"
linecount=STRING|"1"
suppress=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""SOURCEDIR"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SOURCEDIR"
varvalue=STRING|"c:\incoming"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TEXT"" with value """""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TEXT"

[Actions\Action4]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|0
Name=STRING|"Delete File"
Params=FOLDER

[Actions\Action4\Params]
Count=STRING|"1"
deletedirs=STRING|"0"
file0=STRING|"{TargetFile}"
hidden=STRING|"1"
subdir=STRING|"0"
system=STRING|"1"
ToRecycleBin=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CNT"" with value ""1"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CNT"
varvalue=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action6\Params]
createmode=STRING|"1"
date1=STRING|"20150109"
date2=STRING|"20150109"
destvar=STRING|"CURRENTFILE"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{SourceDir}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action7\Params]
message=STRING|"{cnt}; {CurrentFile}"
type=STRING|"3"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{EOL}*******************{EOL}File: {CurrentF..."""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{EOL}*******************{EOL}File: {CurrentFile}{EOL}*******************{EOL}{TextFile({CurrentFile})}"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""cnt"""
Params=FOLDER

[Actions\Action9\Params]
incement=STRING|"1"
vaiable=STRING|"cnt"

Save the text of the task into a file and use menu Task->Import to import the task into RoboTask.
Oleg Yershov
vbigdeli
Posts: 34
Joined: Mon Sep 15, 2008 2:53 am

Re: Join text files into one file

Post by vbigdeli »

Oleg,
I have more than 5000 text files and it takes a lot of time with Write text file.it would takes more than 10 mins with a Intel i7 4790k system & samsund SSD 850 Pro.

I need Join text files task to do it much more faster .

Thanks.
Oleg
Site Admin
Posts: 3011
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Join text files into one file

Post by Oleg »

I optimized the 2-nd task
Try 3-d version below. I tested it. It processed more than 6000 files in 3 minutes.

I prohibited the expand of nested variables. This brakes the process very mach.
I used the expressions {#Text} and {#TextFile({CurrentFile})}. See steps #9, #14, #20

Of course the speed depends on size of files, but speed was increased.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1206"
Hide=INTEGER|0
ID=INTEGER|18567467
LogOnAsUser=INTEGER|1
Name=STRING|"Join TXT file in folder to one file (version 3)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TARGETFILE"" with value ""d:\dest\target.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TARGETFILE"
varvalue=STRING|"d:\dest\target.txt"

[Actions\Action10]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""cnt"""
Params=FOLDER

[Actions\Action10\Params]
incement=STRING|"1"
vaiable=STRING|"cnt"

[Actions\Action11]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""total"""
Params=FOLDER

[Actions\Action11\Params]
incement=STRING|"1"
vaiable=STRING|"total"

[Actions\Action12]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action12\Params]
case=STRING|"0"
operator=STRING|"2"
type=STRING|"1"
value1=STRING|"{cnt}"
value2=STRING|"1000"

[Actions\Action13]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action13\Params]
message=STRING|"Writing target file"
type=STRING|"3"

[Actions\Action14]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TargetFile}"
Params=FOLDER

[Actions\Action14\Params]
encode=STRING|"0"
fileexists=STRING|"1"
filname=STRING|"{TargetFile}"
line0=STRING|"{#Text}"
linecount=STRING|"1"
suppress=STRING|"1"

[Actions\Action15]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value """""
Params=FOLDER

[Actions\Action15\Params]
expand=STRING|"0"
varname=STRING|"TEXT"

[Actions\Action16]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""CNT"" with value ""1"""
Params=FOLDER

[Actions\Action16\Params]
expand=STRING|"0"
varname=STRING|"CNT"
varvalue=STRING|"1"

[Actions\Action17]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action18]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action19]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action19\Params]
message=STRING|"Writing target file"
type=STRING|"3"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""SOURCEDIR"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SOURCEDIR"
varvalue=STRING|"c:\incoming"

[Actions\Action20]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TargetFile}"
Params=FOLDER

[Actions\Action20\Params]
encode=STRING|"0"
fileexists=STRING|"1"
filname=STRING|"{TargetFile}"
line0=STRING|"{#Text}"
linecount=STRING|"1"
suppress=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TEXT"" with value """""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TEXT"

[Actions\Action4]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|-1
Name=STRING|"Delete File"
Params=FOLDER

[Actions\Action4\Params]
Count=STRING|"1"
deletedirs=STRING|"0"
file0=STRING|"{TargetFile}"
hidden=STRING|"1"
subdir=STRING|"0"
system=STRING|"1"
ToRecycleBin=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CNT"" with value ""1"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CNT"
varvalue=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TOTAL"" with value ""1"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TOTAL"
varvalue=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action7\Params]
createmode=STRING|"1"
date1=STRING|"20150109"
date2=STRING|"20150109"
destvar=STRING|"CURRENTFILE"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{SourceDir}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action8]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action8\Params]
message=STRING|"{total}; {CurrentFile}"
type=STRING|"3"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{#Text}{EOL}*******************{EOL}File: {Current..."""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{#Text}{EOL}*******************{EOL}File: {CurrentFile}{EOL}*******************{EOL}{#TextFile({CurrentFile})}"


Oleg Yershov
Post Reply