Computing Staff
  • 1

A Batch File That Will Combine Multipule .Csv Files Into One

  • 1

i have found a .bat file that is really close however being new to .bat files i can’t figure out how to remove the filename off the end. i am needing it to combine all the files in a folder, and remove the headers. a little snag is that a couple of the files have certain headers but a few have a couple more.
i can post the file if needed

Share

1 Answer

  1. I didn’t try to use the script you posted – it was way too confusing for me. I tried from “ground up”, and this seems to work with my limited testing:
    @echo off >mainfile & setlocal enabledelayedexpansion
    for /f %%z in (‘dir /b /x *.csv’) do (
    echo FILE:%%z
    set /p test=>mainfile echo %%a
    goto :eof
    :14
    echo %1:at fourteen
    for /f “skip=1 tokens=1-3,5-8,9* delims=,” %%a in (%1) do >>mainfile echo %%a,%%b,%%c,%%d,%%e,%%f,%%g,%%i
    goto :eof
    :end
    this sets all lines to 12 elements, and of course skips all the header lines (you might need to put the first one back in). No account taken for char.s hazardous to batchscript health and stability in the filestream.
    ps: left a lot of debugging turds in the script. filter them out when things are working…

    • 0