Delete all the columns except 1st column and 1st row in all the csv file in a folder using batch file -


i have hundreds of csv files in 1 folder, having 9 columns ,wherein want delete last 8 columns , 1st row files.

file looks enter image description here

also not sure if can overwrite the same file edited. considering possible. , if overwriting not possible should save same file name may in different directory

please suggest

any appreciated.

this code assumes you've put batch file in same directory csv files.

@echo off  /f %%a in ('dir /b *.csv') (     /f "skip=1 tokens=1,2* delims=," %%b in (%%a) (         echo %%b>>newdata.csv     )     copy /y newdata.csv %%a     del newdata.csv ) 

and code makes no assumptions location of script, source csv files, or target folder:

@echo off  set source_folder=c:\path\to\your\csv\files set target_folder=c:\path\to\your\output\folder  if not exist %target_folder% mkdir %target_folder%  /f %%a in ('dir /b %source_folder%\*.csv') (     /f "skip=1 tokens=1,2* delims=," %%b in (%source_folder%\%%a) (     echo %%b>>%target_folder%\%%a     ) ) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -