您的位置:首页 > 其它

批量生成非动画bci图片的工具

2006-10-27 18:07 417 查看
批量生成非动画bci图片的工具

摘要:

BMP转换成BCI的批量处理工具。使用前设置一下BREW_AuthTool程序路径的环境变量。

' 用法:
' 将包含BMP的文件夹托拽到该脚本文件上执行。
' 生成的bci文件将放在该文件夹的bci/子目录中。

' 执行前保证BMP文件夹中没有 disc/ 和 bci/ 2个子目录。
'

双击脚本可获得帮助信息

正文:

脚本文件内容

' BCI单图自动生成.vbs' 将指定文件夹中的bmp文件转换为bci文件。
'
' 用法:
' 将包含BMP的文件夹托拽到该脚本文件上执行。
' 生成的bci文件将放在该文件夹的bci/子目录中。
'
' 注意:
' 使用前需要设置一下BREW_AuthTool路径的环境变量。
' 执行前保证BMP文件夹中没有 disc/ 和 bci/ 2个子目录。
'
' 2006/10/24
' by D.H.

'-------------------------------------------------
' APP NAME
APP_NAME = "BREW-BCI单图批量生成工具"

'-------------------------------------------------
' 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 = "将bmp文件夹托拽到该脚本文件上。" & vbCr
usage = usage & "或者命令执行:脚本名 bmp文件夹名字" & vbCr & vbCr
usage = usage & "确保BMP文件中没有子文件夹 ./disc/;./bci/ " & vbCr
usage = usage & "生成的bci存放的子目录 bci/ 中。" & vbCr & vbCr
usage = usage & "确保设置了BREW_AuthTool路径的环境变量。"
MsgBox usage, vbInformation, APP_NAME
WScript.Quit
End If

'---------------------------
' path Setting
If not fs.FolderExists( parentDir ) Then
MsgBox "BMP文件夹不存在!", vbCritical, APP_NAME
WScript.Quit
End If
Set parentFolder = fs.GetFolder( parentDir )

' bci描述文件目录
discDir = parentDir & "disc/"
If not fs.FolderExists( discDir ) Then
fs.createFolder( discDir )
End If
Set discFolder = fs.GetFolder( discDir )

' bci生成目录
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

'---------------------------------------
' 收尾工作
If fs.FolderExists( discDir ) Then
fs.DeleteFolder( discFolder.path )
End If

'---------------------------------
' REPORT result
report = "Finished." & vbCr
report = report & "生成: " & fileCnt & " 个bci文件。" & vbCr
report = report & "放在: " + bciDir
MsgBox report, vbInformation, APP_NAME

'****************************
' Function GetFileName
'
Function GetFileName( filename )
GetFileName = Left( filename,InStrRev( filename, "." ) - 1 )
End Function

'****************************
' Function GetFileEx
'
Function GetFileEx( filename )
GetFileEx = Right( filename, Len( filename ) - InStrRev( filename, "." ) )
End Function

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐