; concatenate
;
; Concatenate all the files in the current directory into one big file.
; Useful, e.g., with EDI transaction files that you have just downloaded.
;
; Hint: Add this code to the end of an FTP or Kermit download script.

def result newfile.edi    ; filename for result file.
if exist \m(result) exit 1 \m(result) already exists.
echo Concatenating files to \m(result)...
echo
dir /array:&a *           ; Get list of files
for \%i 1 \fdim(&a) 1 {
    xecho \%i. \&a[\%i] (\fsize(\&a[\%i]))...
    copy /append \&a[\%i] \m(result)
    if fail stop 1 APPEND FAILED
    echo OK
}
echo
echo Done:
dir \m(result)
echo
end
