I would like to create a bat or vbs script to update the date in a CSV file to the current date. The Date column is in the 16th column of the file. The filename is Mailing.cvs. Any help would be greatly appreciated.
Try this lazy way, tested briefly only on Win XP. Input data file Mailing.cvs:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,date today ,17,18 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,todays date,17,18Batch script:
@echo off>mailing1.cvs cls setlocal enabledelayedexpansion for /f "tokens=1-16* delims=," %%A in (mailing.cvs) do ( set col1=%%A,%%B,%%C,%%D,%%E,%%F,%%G,%%H,%%I,%%J,%%K,%%L,%%M,%%N,%%O, set col2=%%Q echo !col1!%date%,!col2!>>mailing1.cvs ) type mailing1.cvsOutput data file Mailing1.cvs:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,Thu 07/04/2011,17,18 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,Thu 07/04/2011,17,18If you require the date in a different format you'll have to set and save that format.
Good luck, hope this helps.
Did you Google for an answer before asking the question?
I have tried this (Windows 7) and even after changing the extensions to CSV it is not working, I must be missing something. I appreciate your help. Thank you.
What do you mean by "it is not working"? What result(s) do you get, any error messages? Perhaps there are differences between XP and Win 7.
Did you Google for an answer before asking the question?
I post the batch file in the same directory as the csv file and double click it, There is a brief change in the screen like the batch file ran. When I open the mailing .csv it has not updated the date. I don't get any error messages.
Well, the script you are using does not update mailing.csv it creates a new updated file mailing1.csv which you will see if you add a Pause command as the last line of the script. Did you Google for an answer before asking the question?
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |