How 2 use DOS 2 Delete & Rename Column in Multiple CSV files

September 27, 2012 at 21:25:59
Specs: Windows 7
Hello everyone,

I have multiple csv file with the following heading:


I want to delete the <ticker> column and rename the <name> into <ticker>

How can I do it via dos command?

Thanks for your help in advance.

See More: How 2 use DOS 2 Delete & Rename Column in Multiple CSV files

Report •

September 27, 2012 at 21:56:13
not sure...

@for /f "skip=1 tokens=2* delims=," %%a in ('source') do >> source.out echo %%a
::===== end

not sure what you want with the headers, so i skipped them for now.

Report •

September 27, 2012 at 22:09:35
thanks for your reply, and sorry for the confusion...

I want the headers become like this:


but with the data below the <ticker> being the data below the <name> originally and the original <ticker> column together with its data underneath it deleted all together.

Report •

September 28, 2012 at 18:15:16
ok. try this one then:

@echo off & setlocal enabledelayedexpansion
echo target filename is 'source'
echo output should be 'source.out' in the same directory as 'source'
set pt=
if "%1" equ "" (
set /p pt=full path without filename:
) else (
set pt=%1
echo selected path: %pt%
pushd %pt%
for /f "tokens=1* delims=," %%a in (source) do (
set x=%%b
set x=!x:name=ticker!
>> source.out echo !x!
::===== end

Report •

Related Solutions

September 29, 2012 at 03:23:17
sorry, it does not might be caused by I don't know how to edit source and source.out part...I tried to replace in (source) to in (C:\XXX\XXX\*.csv) and I retain >> source.out as it is...did I miss anything?

Report •

September 29, 2012 at 19:05:57
yeah, my fault. (sigh) I get so tired of managing paths... so i usually put that off till last. Just to test, try dropping the batchfile into a directory that contains a copy of "source", cd to that directory, and run it from there. I will fix the batch to do that.

Report •

Ask Question