Last active
February 11, 2018 03:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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