Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Find / Replace text in a batch file

Original Message
Name: sfitzger
Date: September 7, 2007 at 07:46:52 Pacific
Subject: Find / Replace text in a batch file
OS: Windows 2000
CPU/Ram: dont know
Model/Manufacturer: hp
Comment:
I have tried to accomplish this but without luck. I run a .bat file everyday to pull 10 .nmon files down from a server then anaylze them. The files contain the date -1 day previous which u can see in my script. What I am trying to do is replace the date in the script.txt file with the %mydate% variable so I don't have to manually change it everday when I run the bat. Please let me know if u can help thanks!


::==
::@echo off
for /f "tokens=2" %%d in ('echo %date%') do (
for /f "tokens=1-3 delims=/" %%j in ('echo %%d') do (
set month=%%j
set day=%%k
set year=%%l
)
)
set /a day=%day%-1
if %day% lss 10 (
set day=0%day%
)
if %day%==00 (
set day=01
)
set year=%year:~2,3%
set mydate=%month%%day%%year%
cd C:\NmonReports
mkdir %mydate%
mkdir %mydate%-reports
pause
ftp -i -s:C:\script.txt
pause
copy C:\NmonReports\*.nmon C:\NmonReports\%mydate%
"C:\Program Files\WinZip\WZZIP.EXE" -a -P -r C:\NmonReports\%mydate% "C:\NmonReports\%mydate%"
move C:\NmonReports\%mydate%.zip C:\NmonReports\%mydate%
pause
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\nmon analyser v317.xls"
"C:\Program Files\WinZip\WZZIP.EXE" -a -P -r C:\NmonReports\%mydate%-reports "C:\NmonReports\%mydate%-reports"
copy C:\NmonReports\%mydate%-reports.zip E:\
del C:\NmonReports\*.nmon
pause


Report Offensive Message For Removal


Response Number 1
Name: Razor2.3
Date: September 9, 2007 at 18:05:50 Pacific
Subject: Find / Replace text in a batch file
Reply: (edit)
You'll have to have the batch file build the script.txt file, and insert the date in there.

Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: September 10, 2007 at 08:32:07 Pacific
Subject: Find / Replace text in a batch file
Reply: (edit)
Your method of calculating the date of the previous day has a bug. If it's the 1st day of the month, you set day to 00 then the very next if statement sets it back to the 1st (formating it with a leading 0) instead of the last day of the previous month.

Report Offensive Follow Up For Removal

Response Number 3
Name: sfitzger
Date: December 10, 2007 at 12:21:47 Pacific
Subject: Find / Replace text in a batch file
Reply: (edit)
Thanks guys, I think I got it figured out :-)

Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Find / Replace text in a batch file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC