Hi.
I created c:\x.bat for testing purposes with following lines:
echo start c:\monday.html >> c:\test.bat
echo del 0% >> c:\test.bat
but when opening test.bat second line is
del “C:\x.bat”
not
del 0%
what’s wrong with the syntax?
thanks
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Here you go much simpler…
@echo off
cls
color 04
Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-4,4%
Set TodaysDate=%Year%-%Day%-%Month%
Set LogPath=W:\TTT\
Set LogFileExt=.log
Set LogFileName=ALFA
Set MyLogFile=%LogPath%%TodaysDate%_%LogFileName%%LogFileExt%
NET USE P: /DELETE /Y
NET USE P: \\Ser5\public\TTT\1\mnt\disk_u\HOME
if exist “P:\c_data.DA1″ (
Call copyfile
)else(
echo File Does not exist. >> %MyLogFile%
)
goto :EOF
:copyfile
move /Y T:\HOME\c_data.DA1 T:\HOME\copy\
copy /Y /Z P:\c_data.DA1 T:\HOME\c_data.DA1
if errorlevel 1 (
Call :Errorlog
copy /Y /Z P:\c_data.DA1 T:\HOME\c_data.DA1
if errorlevel 1 (
Call :Errorlog
move /Y T:\HOME\copy\c_data.DA1 T:\HOME\c_data.DA1
)
)
goto :EOF
:errorlog
echo.%Date% >>”%MyLogFile%”
echo.%Time% >>”%MyLogFile%”
echo.ALFA !!!no connection!!! >>”%MyLogFile%”
call :waitfor
goto :EOF
:waitfor
ping -n 5 127.0.0.1 > nul
goto :EOF
NOT TESTED but you can see how the use of CALL will make your code simpler. Look the command up and it will help you with scripting.
http://www.robvanderwoude.com/call.php
I am sure some one will take this code and simplify it even more.
C:\>copy con a.cmd
@echo ^%0^Z
1 file(s) copied.
C:\>a
a
C:\>
Try %% instead.
echo start c:\monday.html >> c:\test.bat
echo del c:\test.bat >> c:\test.bat
don’t know why you are making it so hard?
You could also do something like…
Set CreateFile=c:\test.bat
echo start c:\monday.html >> %CreateFile%
echo del %CreateFile% >> %CreateFile%