Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append txt in dir to a big file 1

Status
Not open for further replies.

2009luca

Programmer
Jul 27, 2013
222
IT
I have in c:\mydir\:
test.txt
test1.txt
aaa.txt
...
rrr.txt

i need to loop in dir and append all .txt file from c:\mydir\ in a big.txt file in c:\mydir1\big.txt

how to?

note:
the dimension of sigle .txt file is approx 20/30 Mb
 
Simply appending files without any other logic is a work for system commands.
It would be easy done in one command file:

append_files.cmd
Code:
@[COLOR=#008080]echo[/color][COLOR=#804040][b] off[/b][/color]
[COLOR=#008080]echo[/color][COLOR=#ff00ff] Appending files to .\result\big.txt[/color]
[COLOR=#804040][b]for[/b][/color] [COLOR=#6a5acd]%%[/color]i in (.\*.txt) do (
  [COLOR=#008080]echo[/color][COLOR=#ff00ff] appending: [/color][COLOR=#6a5acd]%%[/color][COLOR=#ff00ff]i[/color]
  [COLOR=#008080]type[/color] [COLOR=#6a5acd]%%[/color]i[COLOR=#804040][b] >> [/b][/color].\result\big.txt
)
[COLOR=#008080]echo[/color][COLOR=#ff00ff] Done.[/color]
 
hi mikrom tks for code, sorry me, but i'm in vb6.

... and i need to substituite .\ with my path c:\mydir\?
 
Quite. There are a load of non-VB ways of doing this. E.g. a Powershell variant (and there are loads of ways of doing it in Powershell):

Get-Content (Get-ChildItem -Filter *.txt)>merged.txt
 
2009luca said:
... sorry me, but i'm in vb6
... and i need to substituite .\ with my path c:\mydir\?
It would be not problem to pass to the script your path as a command line argument.

But if like to write it in Visual Basic, maybe this little example I posted some time ago in VBscript forum could help you a little bit:
I guess in VB6 should it be very similar.

 
@mikrom, try not to step on another member's response. Strongm posed his first response for a purpose that required the OP to respond. Might have been good to know where the OP had progressed to in order to understand where the next step might be. You came in like a bull in a china shop. O.L.



Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
@SkipVought
I apologize.
Yes it's my bad habit be impatient and try to solve everything as quickly as possible.
 
This is for the benefit of the OP and other browsers.[glasses]

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
sorry but very busy...
in other case the code work perfect!
Tks
 
If the "other case the code work perfect!", doesn't the "other case"'s post deserve a star? [ponder]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top