'Bci Single chart automatically generated. vbs'Convert the BMP file in the specified folder to a BCI file.
'
'Usage:
'Drag the folder containing BMP to the script file for execution.
'The generated BCI file will be placed in the BCI/subdirectory of this folder.
'
'Note:
'Before use, you need to set the environment variable of the brew_authtool path.
'Make sure that the BMP folder contains no disc/and BCI/subdirectories before execution.
'
'2006/10/24
'By D. H.
'-------------------------------------------------
'App name
App_name = "BREW-BCI Single chart batch generation tool"
'-------------------------------------------------
'Brew BCI authoringtool path
Brew_bci_tool = "brew_authtool.com"
'---------------------------
'Init Shell
Set wshshell = Createobject ("wscript. Shell ")
'---------------------------
'Filesystem init
Dim FS
Set FS = Createobject ("scripting. FileSystemObject ")
Const forreading = 1, forwriting = 2, forappending = 8
'---------------------------
'Access arguments
Set ARGs = wscript. Arguments
If args. Count> 0 then
Parentdir = ARGs (0 )&"/"
Else
Usage = "drag the BMP folder to the script file. "& Vbcr
Usage = Usage & "or command execution: Script Name: BMP folder name" & vbcr
Usage = Usage & "make sure there are no subfolders In the BMP file./disc/;./BCI/" & vbcr
Usage = Usage & "the generated BCI is stored in the subdirectory BCI. "& Vbcr
Usage = Usage & "make sure that the environment variable of the brew_authtool path is set. "
Msgbox usage, vbinformation, app_name
Wscript. Quit
End if
'---------------------------
'Path setting
If not fs. folderexists (parentdir) then
Msgbox "BMP Folder does not exist! ", Vbcritical, app_name
Wscript. Quit
End if
Set parentfolder = FS. getfolder (parentdir)
'Bci description file directory
Discdir = parentdir & "disc /"
If not fs. folderexists (discdir) then
FS. createfolder (discdir)
End if
Set discfolder = FS. getfolder (discdir)
'Bci generated directory
Bcidir = parentdir & "BCI /"
If not fs. folderexists (bcidir) then
FS. createfolder (bcidir)
End if
Set bcifolder = FS. getfolder (bcidir)
'------------------------------------
'Create TXT discription File
Set fc = parentfolder. Files
For each srcfile in FC
Fname = getfilename (srcfile. Name)
Fext = getfileex (srcfile. Name)
If lcase (fext) = "BMP" then
Filename = discdir & fname & "." & "TXT"
Set F = FS. createtextfile (filename)
F. writeline (srcfile. Path)
F. Close
End if
Next
'---------------------------------------
'Create BCI File
Set fc = discfolder. Files
Filecnt = 0
For each txtfile in FC
Fname = getfilename (txtfile. Name)
Fext = getfileex (txtfile. Name)
'Msgbox brew_bci_tool & "-I" & txtfile. Path & "-o" & bcidir & fname & ". BCI"
Wshshell. Run "% comspec %/C" & brew_bci_tool & "-I" & txtfile. Path & "-o" & bcidir & fname & ". BCI", true
Filecnt = filecnt + 1
Next
'---------------------------------------
'Finishing the work
If fs. folderexists (discdir) then
FS. deletefolder (discfolder. Path)
End if
'---------------------------------
'Report result
Report = "finished." & vbcr
Report = Report & "Generation:" & filecnt & "BCI files. "& Vbcr
Report = Report & "put in:" + bcidir
Msgbox report, vbinformation, app_name
'****************************
'Function getfilename
'
Function getfilename (filename)
Getfilename = left (filename, limit Rev (filename, ".")-1)
End Function
'****************************
'Function getfileex
'
Function getfileex (filename)
Getfileex = right (filename, Len (filename)-limit Rev (filename ,"."))
End Function