changing references to a csv file in a html file

i have a webpage that is displaying .csv files
the .csv files are named 05History0418.csv "DDHistoryMMYY"
they are all stored in a folder, i then have a html page for the last 10 files
i am trying to make a batch file that will adjust the page automatically, so it would search each html file and replace the path of the last csv to the appropriate one.
@echo off

set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%

set year=%date:~-2%
echo year=%year%
set month=%date:~4,-8%
if "%month:~0,1%" == " " set month=0%month:~1,1%
echo month=%month%
set day=%date:~7,-5%
if "%day:~0,1%" == " " set day=0%day:~1,1%
echo day=%day%

set datef=%hour%-%day%-%month%-%year%
set dayf=%month%-%day%-%year%
set "d1=%day%History%month%%year%.csv"

echo datetimef=%datef%
echo %dayf%
echo %d1%

pause

:: yesterdays date

set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d2=%dd%History%mm%%yy%.csv"

set day=-2
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d3=%dd%History%mm%%yy%.csv"

set day=-3
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d4=%dd%History%mm%%yy%.csv"

set day=-4
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d5=%dd%History%mm%%yy%.csv"

set day=-5
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d6=%dd%History%mm%%yy%.csv"

set day=-6
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d7=%dd%History%mm%%yy%.csv"


set day=-7
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d8=%dd%History%mm%%yy%.csv"

set day=-8
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d9=%dd%History%mm%%yy%.csv"

set day=-9
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "d0=%dd%History%mm%%yy%.csv"

set day=-10
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YY=%result:~2,2%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "da=%dd%History%mm%%yy%.csv"


echo "%d1%"
echo "%d2%"
echo "%d3%"
echo "%d4%"
echo "%d5%"
echo "%d6%"
echo "%d7%"
echo "%d8%"
echo "%d9%"
echo "%d0%"
echo "%da%"
pause


set findtext=/r /c:"??History????.csv"
set htm1="Z:\OP\WEB\CSV2\d1.html"
set htm2="Z:\OP\WEB\CSV2\d2.html"
set htm3="Z:\OP\WEB\CSV2\d3.html"
set htm4="Z:\OP\WEB\CSV2\d4.html"
set htm5="Z:\OP\WEB\CSV2\d5.html"
set htm6="Z:\OP\WEB\CSV2\d6.html"
set htm7="Z:\OP\WEB\CSV2\d7.html"
set htm8="Z:\OP\WEB\CSV2\d8.html"
set htm9="Z:\OP\WEB\CSV2\d9.html"
set htm0="Z:\OP\WEB\CSV2\d0.html"


echo %findtext%
pause

Open in new window

so d1.html would have every entry referencing a csv as 05History0418.csv
and d2.html would have every entry refrencing a csv as 04History0418.csv... ETC
i have tryed a few things and it keeps returning nothing or erroring out, help would be apreciated.
LVL 1
csePixelatedAsked:
Who is Participating?
 
csePixelatedConnect With a Mentor Author Commented:
So I am reworking how I am doing this, instead I will be making the web page static and the script I am using to get my csv's will simply write the the last 10 days as an individually named csv's, according to where they should land on the page.

I once could get in touch with a moderator who would advise as to how i should rap up this question (as it is not solved) - I cannot find this option anymore.
0
 
csePixelatedAuthor Commented:
so I have tryed adding this
https://www.howtogeek.com/51194/replace-text-in-plain-text-files-from-the-command-line/
however im not sure if it is having issues using variables, as,
ReplaceText “Z:\OP\WEB\CSV2\d1.html” %findtext% %d1%

Open in new window

&
ReplaceText “%htm1%” "%findtext%" "%d1%"

Open in new window

at the end of my batch always errors out with "Specified file does not exist ."
0
 
Bill PrewConnect With a Mentor Commented:
Do you really need a BAT to drive this?  If it was me I would create one VBS script that does the whole job, updating each of the 10 html files as needed.  Is that something that would work for you, or is there a reason it needs to be this way?

Also, is it possible to share sample(s) of the HTML files?


»bp
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
csePixelatedAuthor Commented:
There is no reason it needs to be a batch, I just need a scheduled task that changes the html files once per day, i figured as i am using a batch to robocopy the csv files once per day i could simply make it part of this batch file, VBS is completely alien to me so i would be starting at square 1.
0
 
csePixelatedAuthor Commented:
honestly it would be great if i could have a html generated for each new csv file matching the naming criteria [DD]History[MMYY], and I could add a link to the top of the Indexl.html file. however i was not 100% sure how to do that either, I thought this approach in batch would be simpler
d1.html
d2.html
d3.html
0
 
Bill PrewCommented:
csePixelated

Take a look at this article, it should help you with the question close process.  If not let me know and I will assist...


For future reference here some other items related to closing questions in case they are helpful.


And don't forget you can always "Report Question" on a question if you are not sure how to proceed and a support person will be in touch to help you out.


»bp
0
 
csePixelatedAuthor Commented:
I am reworking how I am doing this, instead I will be making the web page static and the script I am using to get my csv's will simply write the the last 10 days as an individually named csv's, according to where they should land on the page.
 
In lieu of this no solution was presented for this question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.