combine multiple files into single file

G

Guest

Hi, guys!

Running A2K, need to copy multiple text files to a single, new text file.
FileCopy assumes that the destination is a folder if wildcards are used for
the source, so I get an "Invalid Path" error when running the following code:

Dim fs
set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile "C:\*.txt", "C:\CombinedFile.txt"

Can anyone help with another way to do this?

Thanks,
BruceS
 
J

John Nurick

Hi Bruce,

Something like

shell("CMD.EXE /C COPY F1.txt + F2.txt + F3.txt new.txt")
 
G

Guest

John,
Thanks for help! Took me a couple of tries to get the syntax correct when
using variables for the names, but did get it to work. (Had to manually add
quotes [Chr(34)] around the file names because they contained embedded
spaces. Apostrophes won't work there.)
BruceS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top