Combined csv via cmd -


i'm working on way combine 3 csv files , have following script so:

script

@echo off  echo set working directory pushd %~dp0  setlocal enabledelayedexpansion  set cnt=1  %%i in (*.csv) (  if !cnt!==1 (  /f "delims=" %%j in ('type "%%i"') echo %%j >> combined.csv       ) else if %%i neq combined.csv (   /f "skip=1 delims=" %%j in ('type "%%i"') echo %%j >>            combined.csv   ) rem increment count 1   set /a cnt+=1 )' 

this works charm , strips header of other 2 csv files in working dir.

the script outputs combined.csv, nice script output nl2 ddmmyyyy.csv.

the issue have , can't seem figure out how make name of output file incremental , date-based.

code can parse date elements date variable. format of date vary based on locale. mine set yyyy-mm-dd, yours may different.

m:>echo %date% 2016-01-27   8:23:58.28 \\swpdcendwxtk01\d$  m:\dw_devl\paul\phs_dmx_config\bin m:>set fndate=%date:~8,2%%date:~5,2%%date:~0,4%   8:24:08.54 \\swpdcendwxtk01\d$  m:\dw_devl\paul\phs_dmx_config\bin m:>echo %fndate% 27012016 

inside loop, set variable , use output.

set combo_filename=nl!cnt!%fndate%.csv echo %%j >>!combo_filename! 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -