.key Infile/A,Type,Freq/K,Bits/K
.default Type 8svx
.default Freq no
.default Bits no

; AmigaDOS Script For Handling Simple Conversions With SOX.
; By Peter Bengtsson <a94petb@ida.his.se> 960119.
; Updated 981216.

; Syntax is : x2y <Filename[.ext]> [Type]
; Where type is one of {iff,8svx,voc,vaw,au,aiff}

; $VER: x2y 1.1 (16.12.98)

Set AFile <InFile>
Set Hz ""
Set Bps ""

If Not Exists "$AFile"
   Set AFile `List <InFile>.(voc|wav|8svx|iff|au|aiff) LFormat="%n" Files`
   If "$AFile" EQ "<InFile>"
      Echo "*"*E[2m<InFile>*E[22m*" : No such file."
      Skip End
   Else
      If Not Exists "$AFile"
         Echo "No singular completion of *"*E[2m<InFile>*E[22m*" possible."
         Skip End
      EndIF
   EndIf
EndIf

IF Not <Freq> EQ no
   Set Hz "-r <Freq>"
EndIf

IF Not <Bits> EQ no
   IF <Bits> EQ 8
      Set Bps "-b"
   EndIf

   IF <Bits> EQ 16
      Set Bps "-w"
   EndIf

   IF <Bits> EQ 32
      Set Bps "-l"
   EndIf

   IF "$Bps" EQ ""
      Echo "Valid values for Bits are: 8, 16, 32"
      Skip End
   EndIf
EndIf

Sox -t AUTO "$AFile" $Hz $Bps "`List "$AFile" LFormat="%m"`.<Type>"

Lab End

UnSet AFile
UnSet Hz
UnSet Bps
