Combining Text Files using DOS (1 Viewer)

JDeezy

Registered User.
Local time
Today, 08:33
Joined
Sep 4, 2009
Messages
54
I am having some problems. Right now I have a code that combines files using FSO but for some reason it has been adding an empty line to the end of files and if the file has an empty line it combines that empty line.

The programs that run off these files cannot read this empty line correctly and blow up. I have asked programming to just fix this (very simple fix) but they are pretty dang stubborn over there.

I have looked at using the Shell cmd but I cant get it to work. Any suggestions? Btw right now I am appending all files in the specified folder, running through a loop, and combining them if they match certain criteria.
 

PaulSchrum

Registered User.
Local time
Today, 09:33
Joined
Jul 30, 2011
Messages
20
JDeezy,

I just tried this to be sure it works the way I thought it did.

At the DOS prompt, enter
Code:
type sourceFile.txt >> targetFile.txt

This appends the contents of sourceFile.txt to targetFile.txt. The double > is the keyword for appending. Single > overwrites the previous contents of targetfile.txt.

- Paul
 

JDeezy

Registered User.
Local time
Today, 08:33
Joined
Sep 4, 2009
Messages
54
Thanks paul but thats not exactly what i meant. You can use copy *.txt [FileName] to combined files through the dos prompt as well. but thats not my problem. i have about 1,000 text files a day that I have to use around 100-300 combines for.
I was looking for a more automated way with maybe a Shell command or possible deleting the empty line in the file using fso.
 

PaulSchrum

Registered User.
Local time
Today, 09:33
Joined
Jul 30, 2011
Messages
20
JDeezy,

Maybe my response was a little too sparse, or maybe I am still missing your point.

type file1 >> file2

is the shell command. I apologize if I am offending your intelligence, but you populate file1 and file2 with what ever values you need in VBA, then send that command to the shell in a loop that executes 100 to 300 times.

I am not practiced in composing shell commands in VBA. I have done it, but I have to wait until later this evening to sit down and write it out.

- Paul
 

JDeezy

Registered User.
Local time
Today, 08:33
Joined
Sep 4, 2009
Messages
54
Yeah, thats my problem too. I know some File System Object stuff but not enought to dim a line specific line and delete is based on its values. All I know is that DOS prompt combined the files correctly and I need to somehow code that in VBA.
Without a Batch. Unless somehow I can send values to the batch and run it which not a clue how to that.
 

PaulSchrum

Registered User.
Local time
Today, 09:33
Joined
Jul 30, 2011
Messages
20
I know some File System Object stuff but not enought to dim a line specific line

I've been doing that kind of stuff lately, so I have sample code to draw on. But I have to focus on other stuff right at this moment until later tonight. I will have you something before midnight, Eastern Time, US.

- Paul
 

PaulSchrum

Registered User.
Local time
Today, 09:33
Joined
Jul 30, 2011
Messages
20
JDeezy,

I have not tried this, but I think you can do what you need simply by using the Shell command:

In VBA
Code:
Shell ("type " & sourceFiletxt & " >> " & targetFiletxt)

Please let me know whether or not this works for you.

This is my first attempt at helping someone in any Access forum, so take my advice with a bit of caution. Given that, I hope it works for you.

- Paul
 

Users who are viewing this thread

Top Bottom