Merging/Combining TXT files to CSV

January 12, 2011 at 09:42:49
Specs: Windows XP
Hi there,

I'm working with a windows batch script to create a list of filenames and filepaths in a CSV format for parsing of reports by a document management application. I need to have the path to the file and the actual file name (by itself) to be used as an index value (the application looks up the filename in a SQL DB and brings in the remaining index information). Ideally I'd like to be able to just call a VBScript that will perform the operation as part of the batch process that will run daily.

I've already used DIR commands and another VBscript to produce two files that I will need to combine into a CSV, filelistA.txt and filelistB.txt:

filelistA.txt looks like:
C:\Data\Clients\COLD\AC3060P.txt
C:\Data\Clients\COLD\AC3090P.txt
C:\Data\Clients\COLD\AC3100P.txt
C:\Data\Clients\COLD\AC3150P.txt
C:\Data\Clients\COLD\AC3200P.txt
C:\Data\Clients\COLD\AC3600P.txt
C:\Data\Clients\COLD\AC3652P.txt
C:\Data\Clients\COLD\AC5715P.txt
C:\Data\Clients\COLD\AC5720P.txt
C:\Data\Clients\COLD\AC5725P.txt

filelistB.txt looks like:
AC3060P
AC3090P
AC3100P
AC3150P
AC3200P
AC3600P
AC3652P
AC5715P
AC5720P
AC5725P

I want to make FileListCSV.txt, that looks like this:
C:\Data\Clients\FWBT\COLD\AC3060P.txt,AC3060P
C:\Data\Clients\FWBT\COLD\AC3090P.txt,AC3090P
C:\Data\Clients\FWBT\COLD\AC3100P.txt,AC3100P
C:\Data\Clients\FWBT\COLD\AC3150P.txt,AC3150P
C:\Data\Clients\FWBT\COLD\AC3200P.txt,AC3200P
C:\Data\Clients\FWBT\COLD\AC3600P.txt,AC3600P
C:\Data\Clients\FWBT\COLD\AC3652P.txt,AC3652P
C:\Data\Clients\FWBT\COLD\AC5715P.txt,AC5715P
C:\Data\Clients\FWBT\COLD\AC5720P.txt,AC5720P
C:\Data\Clients\FWBT\COLD\AC5725P.txt,AC5725P

Thanks in advance for your help.


See More: Merging/Combining TXT files to CSV

Report •

#1
January 13, 2011 at 05:57:05
I suspect you're going about this the wrong way:
@(for %%a in (C:\Data\Clients\COLD\*) do @echo %%~Fa,%%~Na)>FileList.csv

How To Ask Questions The Smart Way


Report •

#2
January 13, 2011 at 09:15:57
Yes, I ended up doing a similar variation on the command you listed above. Thanks a lot.

Report •

#3
May 16, 2011 at 02:24:39
Can you please post me the full Program that has worked out.

Thank you.


Report •
Related Solutions


Ask Question