@EXPWRITE — Writes a line to a file, with escapes expanded.

Syntax:
%@EXPWRITE[handle,text]

handlea handle returned by @FILEOPEN
textthe text to write to the file

A carriage return and line feed will be appended to the text automatically.

@echo off
rem   Batch file to test @ESCWRITE:
setlocal
option //unicodeoutput=no

set h1=%@fileopen[%_batchname,r]
set h2=%@fileopen[testfile.out,w]

do
   set line=%@escread[%h1]
   if "%line" == "**EOF**" leave
   set rv=%@expwrite[%h2,%line]
enddo

set rv=%@fileclose[%h1] %@fileclose[%h2]
endlocal

See also: @ESCREAD, which does the reverse.