.key LEFT/A,RIGHT/A,DESTFILE/A
.bra {
.ket }

; This script will convert two Studio 16 files into one stereo AIFF file.
;
; $VER: Studio2StereoAIFF 1.0 (11.11.97)
; Created by Kenneth 'Kenny' Nilsen (kenny@bgnett.no)
;
; USAGE: Studio2StereoAIFF <file_L> <file_R> <destfile>
;
; NOTE: The commands must be in the command search path. To be safe
; copy the commands in C: or add the path where you keep the commands to
; the global search path (startup-sequence: path <path> ADD).

;** check files:

if not exists {LEFT}
    echo "File '{LEFT}' doesn't exist!"
    skip Final
	else
    S16IsStudio {LEFT} >nil:
    If WARN
	echo "File '{LEFT}' is not a Studio 16 file!"
	skip Final
	endif
	else
    S16IsPermanent {LEFT} >nil:
    If WARN
	echo "File '{LEFT}' contains edits!"
	echo "Please make the file permanent and try again."
	skip Final
	endif
    endif

if not exists {RIGHT}
    echo "File '{RIGHT}' doesn't exist!"
    skip Final
	else
    S16IsStudio {RIGHT} >nil:
    If WARN
	echo "File '{RIGHT}' is not a Studio 16 file!"
	skip Final
	endif
	else
    S16IsPermanent {RIGHT} >nil:
    If WARN
	echo "File '{RIGHT}' contains edits!"
	echo "Please make the file permanent and try again."
	skip Final
	endif
    endif

if exists {DESTFILE}
    echo "WARNING: File '{DESTFILE}' already exist!"
    ask "Continue ? (y/N)"
    if not WARN
       echo "Terminating.."
       skip Final
       endif
    endif

;** Ok, start the programs

echo "Converting... please wait"

Studio2AIFF {LEFT} {DESTFILE}_L.a >t:log.16
if WARN
	echo "Error while converting '{LEFT}' to tempfile '{DESTFILE}_L.a' !"
	type t:log.16
	skip Final
	endif

Studio2AIFF {RIGHT} {DESTFILE}_R.a >t:log.16
if WARN
	echo "Error while converting '{LEFT}' to tempfile '{DESTFILE}_L.a' !"
	type t:log.16
	skip Final
	endif

JoinAIFF {DESTFILE}_L.a {DESTFILE}_R.a {DESTFILE} >t:log.16
if WARN
	echo "Error while joining temp files '{DESTFILE}_L.a' and '{DESTFILE}_R.a' !"
	type t:log.16
	skip Final
	endif

Delete {DESTFILE}_L.a {DESTFILE}_R.a >t:log.16
if WARN
	echo "Error deleting temp files!"
	type t:log.16
	skip Final
	endif

Delete t:log.16 >nil:

;** We're done

Echo "Done"
Echo ""

Lab Final
