将文本文件数据附加到日志文件.bat

时间:2022-05-03 13:57:20

This .bat file is used for website replication, transferring files from development to production and then produces a log file with job statistics. I'd like to include the contents of a text file at the end of the log file. Is there an easy way to do this?

此.bat文件用于网站复制,将文件从开发传输到生产,然后生成包含作业统计信息的日志文件。我想在日志文件的末尾包含文本文件的内容。是否有捷径可寻?

@ECHO off
    IF "%1"=="" goto :Syntax
    for %%d in (%1) do call :sub0 %%d
    goto :END

    :sub0
    Echo Replicating Site %1
    rem subinacl /subdirectories D:\inetpub\%1\*.* /setowner=Administrators REM /grant=Administrators=f /grant=SYSTEM=f
    robocopy D:\inetpub\%1 \\111.111.11.11\D$\inetpub\%1 /MIR /ZB /NP /R:3 /W:3 /XD SiteReplication /XD SiteLogs /XD Administration /XD sitestatistics /XF calendar_secure.asp /XF navigation_editor.asp  /LOG:logs\test%USERNAME%.log
    robocopy D:\inetpub\%1 \\111.111.11.11\D$\inetpub\%1 /MIR /ZB /NP /R:3 /W:3 /XD SiteReplication /XD SiteLogs /XD Administration /XD sitestatistics /XF calendar_secure.asp /XF navigation_editor.asp  /LOG+:logs\test.log


    goto :EOF

    :Syntax
    ECHO Usage:  _REP_SITE WEB_Site
    ECHO.
    ECHO Where:  "WEB_Site"   is the name of the folder you want to replicate
    ECHO                      i.e. _REP_SITE www.test.com
    ECHO.
    goto :END

    :END
    exit

1 个解决方案

#1


Something like:

type textfile.txt >> test.log

?

(Note that in the batch file it looks like you're currently creating two separate log files. Is that deliberate?)

(请注意,在批处理文件中,您似乎正在创建两个单独的日志文件。这是故意的吗?)

Alternatively, if you need to copy the files elsewhere you can just do:

或者,如果您需要将文件复制到其他位置,您可以执行以下操作:

copy test.log+textfile.txt destination.log

That creates destination.log from test.log with textfile.log appended on the end.

这将从test.log创建destination.log,并在末尾附加textfile.log。

#1


Something like:

type textfile.txt >> test.log

?

(Note that in the batch file it looks like you're currently creating two separate log files. Is that deliberate?)

(请注意,在批处理文件中,您似乎正在创建两个单独的日志文件。这是故意的吗?)

Alternatively, if you need to copy the files elsewhere you can just do:

或者,如果您需要将文件复制到其他位置,您可以执行以下操作:

copy test.log+textfile.txt destination.log

That creates destination.log from test.log with textfile.log appended on the end.

这将从test.log创建destination.log,并在末尾附加textfile.log。