Skip to content

Instantly share code, notes, and snippets.

@torutk
Last active February 11, 2018 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torutk/1384d64fb021a32c5694584b3c784b9d to your computer and use it in GitHub Desktop.
Save torutk/1384d64fb021a32c5694584b3c784b9d to your computer and use it in GitHub Desktop.
append multiple csv file with eliminating top line from each file but except for 1st file.
@echo off
rem 複数のcsvファイルを1つのcsvファイルに結合する。
rem その際、2番目以降のCSVファイルは先頭行を除去する。
rem 本バッチファイルのあるディレクトリをカレントディレクトリにする
cd /d %~dp0
rem 結合ファイル
set resultfile=result.csv
setlocal enabledelayedexpansion
set num=0
for %%f in (csv\*.csv) do (
if !num! equ 0 (
copy %%f %resultfile%
) else (
echo 2つ目以降のファイルは結果ファイルに結合
for /f "tokens=* skip=1" %%l in (%%f) do (
echo %%l>>%resultfile%
)
)
set /a num+=1
)
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment