Add file date column to CSV

March 30, 2009 at 00:43:16
Specs: Windows XP
I would like to add the file date in a new column for each entry in the CSV file
From this:
To this:

Im sure there is an easier way than manual input


See More: Add file date column to CSV

Report •

March 30, 2009 at 06:39:34
You can do that using a batch script.

:: MYCSV.BAT  Usage: mycsv File_Name
@echo off & setlocal > output.csv
set filedate=%~t1
set filedate=%filedate:~0,10%
for /F "delims=" %%j in (%1) do echo.%%j,%filedate%>> output.csv
del "%1"
ren output.csv "%1"
:: End_Of_Batch

Where File_Name must not have embedded blanks.

Report •

March 30, 2009 at 07:28:41
I created the batch file and saved it in the directory where all my csv files are, then ran the batch file and all that happened is all my files disapeared. I do have backups.

Im quite new at this, so what did i do wrong?

Report •

March 30, 2009 at 13:05:04
First of all never try a script or program without backing-up the involved data! Now have you typed

mycsv FileName.csv

as the batch processes just one file a time. If no operands are specified what you reported is possible. Please, report exactly what you typed, as I have the deal to give you the script working as you need.

File names must not have spaces and the date has full four year digits, but that may be easily adapted to your format.
When the script works properly I can give you the way to process all the files in one run.

Report •

Related Solutions

Ask Question