自动导出雷神7的fac文件来替换雷神6的相应fac文件

这个是vbs脚本,*.vbs
fnw018.jpg,副官的这张用6代的

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' 本脚本用于复制出雷神7的fac来替换雷神6的相应fac
''' 最后更新 2014/2/12
''' power by ztjal.info
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

dim fso,f1,strfile1,rai7memfile,rai7strline,rai7strlinearr,f2,strfile2,rai6memfile,rai6strline,rai6strlinearr,strfactemp,strfacpath1,strfacpath2

dim rai7csv,rai6csv,rai7facpath,rai6facpath,copy7path,copy6path
' 7代的 pson1 文件全路径
rai7csv="R:\temp6\pson1.csv"
' 6代的 pson1 文件全路径
rai6csv="R:\temp6\rai6c\csv\pson1.csv"
' 上边两个文件的编码必需相同
' 7代的fac文件夹全路径
rai7facpath="G:\Program Files\rai7\fac\"
' 6代的fac文件夹全路径
rai6facpath="R:\temp6\rai6c\fac\"
' 复制7代的fac文件到目标文件夹的全路径, 这个就是要的结果, 将里面的文件复制到6代的fac内覆盖
copy7path="R:\temp6\fac_7\"
' 复制6代的fac文件到目标文件夹的全路径, 这个只是留来比较结果用
copy6path="R:\temp6\fac_6\"

Set fso=CreateObject("Scripting.FileSystemObject")

if not fso.FileExists(rai7csv) then
	wscript.echo "rai7csv no found!"
	wscript.quit
end if
if not fso.FileExists(rai6csv) then
	wscript.echo "rai6csv no found!"
	wscript.quit
end if

if not fso.FolderExists(copy7path) then
	fso.CreateFolder(copy7path)
end if
if not fso.FolderExists(copy6path) then
	fso.CreateFolder(copy6path)
end if

Set f1=fso.OpenTextFile(rai7csv, 1)
strfile1=f1.readall
f1.Close

Set f1=fso.OpenTextFile(rai6csv, 1)
strfile2=f1.readall
f1.Close

if strfile1="" then
	wscript.echo "file1 no line"
	wscript.quit
end if
if strfile2="" then
	wscript.echo "file2 no line"
	wscript.quit
end if

'7代
' 0	 1	   2	3	 4	 5	 6	 7	 8			 9				 10		  11	12   13	14   15	 16	  17   18	 19   20	   21		   22				23					24					 25
'ID,武将名,状態,SP,忠誠,年齢,性別,勲功,知力,艦隊指揮攻撃,艦隊指揮防御,格闘,交渉,父ID,母ID,夫ID,覇王ID,性格,信念,派閥,旗艦,dpm番号,オルドタイプ,村娘埋伏惑星,ロリオルドタイプ,ロリdpm番号

'6代
' 0	 1	   2	 3	4	5		6		 7	 8		9		   10		11	12   13   14	15	16	   17		 18			19	   20	21
'ID,武将名,状態,忠誠,年,性別,旗艦番号,勲功,知力,艦隊指揮,地上戦術,格闘,交渉,奇策,父ID,母ID,夫ID,位置ID,sex性格,ファイル名,sex1,子顔
'																																									  dummy

rai7memfile=split(strfile1,vbcrlf)
rai6memfile=split(strfile2,vbcrlf)

for each rai7strline in rai7memfile
	'wscript.echo rai7strline
	if instr(rai7strline, "/")=0 and instr(rai7strline, ",")>0 then
		rai7strlinearr=split(rai7strline,",")
		'wscript.echo rai7strlinearr(1)
		strfactemp=""
		for each rai6strline in rai6memfile
			if instr(rai6strline, "/")=0 and instr(rai6strline, ",")>0 then
				rai6strlinearr=split(rai6strline,",")
				if strcomp(rai6strlinearr(19),"dummy", 1)<>0 then
					if strcomp(rai7strlinearr(1), rai6strlinearr(1),1)=0 then
						if rai7strlinearr(6)=1 then
							strfactemp="m" & sprintf(rai7strlinearr(0),4)
						elseif rai7strlinearr(6)=2 then
							strfactemp="w" & sprintf(rai7strlinearr(0),4)
						end if
						exit for
					end if
				end if
			end if
		next
		if strfactemp<>"" then
			'wscript.echo strfactemp
			strfacpath1=rai7facpath&strfactemp&".jpg"
			strfacpath2=rai6facpath&rai6strlinearr(19)&".jpg"
			if fso.FileExists(strfacpath1) and fso.FileExists(strfacpath2) then
				fso.CopyFile strfacpath1,copy7path&rai6strlinearr(19)&".jpg"
				fso.CopyFile strfacpath2,copy6path&rai6strlinearr(19)&".jpg"
				strfacpath1=rai7facpath&strfactemp&"b.jpg"
				strfacpath2=rai6facpath&rai6strlinearr(19)&"b.jpg"
				if fso.FileExists(strfacpath1) then
					fso.CopyFile strfacpath1,copy7path&rai6strlinearr(19)&"b.jpg"
				end if
				if fso.FileExists(strfacpath2) then
					fso.CopyFile strfacpath2,copy6path&rai6strlinearr(19)&"b.jpg"
				end if
			end if
		end if
		'wscript.quit
	end if
next

function sprintf(str,length)
	strf=""
	for i=1 to length-Len(str)
		strf=strf&"0"
	next
	sprintf=strf&str
end function

set fso=nothing
wscript.echo "done!"
VB