Hi,

I need to convert a log file from an application (Called InterWorld) to the
IIS format.

The script I write is as follow:
* Get current date,
* Get Current time,
* Copy yesterday logfile from the Interworld apps to where I want to convert
* For every file copied Do the convert of the file via a procedure called
MODIFY
* Move the converted file to a archive directory.

The problem I have is with the command below, which i tried to change the
date format of the logfile from MM/DD/YYYY to YYYY-MM-DD

for /F "tokens=1-20 delims=," %%a in (%1) do (set u=%%c & echo
%u:~6,4%-%u:~0,2%-%u:~3,2% %%d %%a - w3svc1 %%f %%g %%m %%n %%o %%l 0 %%k
%%j %%h 80 HTTP/1.1 - - %%q >> %1.txt)

the output is some thing like this:
D:\Scripts>(set u=08/14/2001   & echo :~6,4u:~0,2u:~3,21.txt )
:~6,4u:~0,2u:~3,21.txt

Can anyone please tell me what I've done wrong.

the program  and a sample input log file are attached.

Program
============================================================================
===
@echo on
Set minday=1
Set maxday=2
set @source=z:\interworld\temp
set @destin=i:\Prodbrk01

:GetDate
FOR /F "TOKENS=2" %%D IN ('DATE /T') DO SET @DATE=%%D

:GetTime
FOR /F %%T IN ('TIME /T') DO SET @TIME=%%T

:CopyFile
Robocopy %@source% %@destin% /MINAGE:%minday% /MAXAGE:%maxday%

For %%z in (%@destin%\*.log) do (call :modify %%z)
Goto End

:modify
setlocal
if exist %1.txt (del %1.txt)
echo #Software: Microsoft Internet Information Server 4.0 >> %1.txt
echo #Version: 1.0 >> %1.txt
echo #Date: %@DATE% %@TIME% >> %1.txt
echo #Fields: date time c-ip cs-username s-sitename s-computername s-ip
cs-method cs-uri-stem cs-uri-query sc-status sc-win32-status sc-bytes
cs-bytes time-taken s-port cs-version cs(User-Agent) cs(Cookie) cs(Referer)
>> %1.txt
for /F "tokens=1-20 delims=," %%a in (%1) do (set u=%%c & echo
%u:~6,4%-%u:~0,2%-%u:~3,2% %%d %%a - w3svc1 %%f %%g %%m %%n %%o %%l 0 %%k
%%j %%h 80 HTTP/1.1 - - %%q >> %1.txt)

copy %1 %@destin%\archive /y
del %1
Endlocal
Goto end


:end
================================================
Input logfile, (wrapped)
================================================
155.144.24.23,"",08/13/2001,23:58:42,InterWorld WebBroker/3.0.1.6
#1,hqifsprodbrk01,155.144.24.23,63,63,73,192,200,GET,/WatchDog.tem,-,"-","-"
,< a6a4a5222262b27d2525c1082bf,-,10.0.9.34:8802
155.144.24.23,"",08/14/2001,00:00:42,InterWorld WebBroker/3.0.1.6
#1,hqifsprodbrk01,155.144.24.23,62,62,73,190,200,GET,/WatchDog.tem,-,"-","-"
,< a6a4a5132262b27d3138af2cc,-,10.0.9.19:8802
================================================
CAUTION

This e-mail and any files transmitted with it are privileged and confidential 
information intended for the use of the addressee. The confidentiality and/or 
privilege in this e-mail is not waived, lost or destroyed if it has been transmitted 
to you in error. If you have received this e-mail in error you must (a) not 
disseminate, copy or take any action in reliance on it; (b) please notify Australia 
Post immediately by return e-mail to the sender; and (c) please delete the original 
e-mail.

http://www.sunbelt-software.com/ntsysadmin_list_charter.htm

Reply via email to