Question Locked

Text file update

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a text file that is a script for sybase 7. In the text file are dates that need to be updated before running a batch file that loads the files into dbisql. Currently I am having to manually update the correct dates before launching the batch files. Not to difficult but I have many date fields and many text files that have to be updated, which takes about 20 minutes. Any way to write data to a text file where there are dates.

Field data looks like this:
and year(transdate) = 2006
and transdate <= '2006-09-30'

Thanks.

2 replies

by toivo talikka

In Linux your input and edit can be achieved with a couple of lines of shellscript. In Windows you will need to write a VB, VBA or KiXtart program, or find a utility to perform simple string replacements. The tool [b]ACSR.exe[/b] is apparently part of the Terminal Server Resource Kit, but there are free utilities like the [b]Swiss File Knife[/b] http://stahlforce.com/dev/index.php?tool=filter.

Here is a batch file that will prompt for the date and copy your batch file template to the output file, replacing strings #year# and #date# with your input:
[pre]
@echo off
set /P year_in=Enter year yyyy :
set /P month_in=Enter month mm :
set /P day_in=Enter day dd :
set my_date=%year_in%-%month_in%-%day_in%
@echo The date is %my_date%
@echo press Enter to continue
@echo ... or Ctrl-C to stop the edit job
pause
acsr.exe "#year#" "%year_in%" W:\my_template.txt W:\temp_file.txt
acsr.exe "#date#" "%my_date%" W:\temp_file.txt W:\actual_script.cmd
[/pre]
Two passes of the input file are required. If you use [b]Swiss File Knife[/b] ,you can specify both string replacements in the same command line.

This discussion is closed to new replies.