『楼 主』:
[请教]PAK导出文件批量改名
使用 LLM 解释/回答一下
游戏中的PAK文件导出格式为:
文件的CRC32校验码.out
例如:
ui\0147E5A6.out
其中有个文件存放原始文件名list.txt,(因为发帖原因,无法看清楚,在每行列与列之间都是TAB分割,时间项(2009-6-30 15:22:1)之间为空格分隔)格式为:
TotalFile:768 PakTime:2009-11-11 11:13:40 PakTimeSave:4afa2be4 CRC:3f91d323
Index ID Time FileName Size InPakSize ComprFlag CRC
0 6bf9d 2009-6-30 15:22:1 \ui\script\window\playerstate.lua 5108 1834 4 4aecede2
1 5e0d8d 2008-10-24 10:1:21 \ui\001a\window\blogviewplayer.ini 9241 1806 4 71579ab8
2 c8f97d 2009-9-23 17:50:16 \ui\001a\worldmap\npcsetting\1622.txt 109 104 4 c461871a
现在要将源文件改名为目标文件,
源文件的文件名为list.txt的最后一列的值CRC,后缀为.out,
目标文件为list.txt对应第四列的值Filename,
例如:
c461871a.out 改为 \ui\001a\worldmap\npcsetting\1622.txt
我是新手,曾试图自己使用 FOR编写,但没有成功
请教各位高手,使用批处理改名,谢谢!
=======================
当前目录:D:\UI
list.txt
第九列为源文件名(注意这里源文件名不带后缀:.out)
第五列为目标文件名
【思路】利用FOR,通过提取list.txt文件的第九列(源文件名不带后缀,4aecede2)修改为完整的源文件名(例如:D:\UI\4aecede2.out),并使用Xcopy 改名为第五列所指向的目标文件名(例如:D:\UI\ui\script\window\playerstate.lua)
=======================
测试记录
自己搞了个,参考下:
for /f "skip=2 tokens=5,9" %i in(list.txt) do command
skip=2 跳过前两行
tokens=5 取目标文件路径
tokens=9 取源文件名
command 执行命令,源文件名改为目标文件名 xcopy %i.out %j
我先去测试下...
错误:%i取到文件名,没后缀,怎么做成%i.out这样的全文件名?
2009-11-23 20:30修改测试:
批处理:
for /f "skip=2 tokens=5,9" %%i in (list.txt) do set var=%%j set de=%%i
显示:
set var=47f384bb
set de=\script\event\zhongqiu_jieri\200809\item\canghaiyueming.lua
目前参量都可以取到,就是无法把var变量(例如:47f384bb)变为源文件名(例如:47f384bb.out)
2009-11-24 2:30修改测试:
当前目录:D:\UI
命令行运行:D:\UI>bat-out.bat out
批处理文件bat-out.bat内容:
@setlocal ENABLEDELAYEDEXPANSION
@cd
@set pth=!cd!
@set suf=%1
for /f "skip=2 tokens=5,9" %%i in (list.txt) do call out.bat %pth% %%j %suf% %%i
@endlocal
批处理文件out.bat内容:
xcopy /f %~dp1%~n2%~x3 %~f4
命令行回显内容:
D:\UI>call out.bat D:\UI\script
ddecb8c2 out \script\event\jieri\200812_xmas\item\xmas_giftbox.lua
D:\UI>xcopy /f D:\UI\ddecb8c2 D:\UI\scriptevent\jieri\200812_xmas\item\xmas_giftbox.lua
找不到文件 - ddecb8c2
复制了 0 个文件
分析:
CALL 批处理的时候,suf环境变量取值正确,但传递到out.bat的时候,即:传递参数%3没有成为%~x3 ,即变为文件的后缀名,所以xcopy找不到文件。
哎,自己无法解决啊,哪位高手解决下,谢谢!
2009-11-26 21:16修改测试:
bat-out.bat 内容:
@setlocal ENABLEDELAYEDEXPANSION
@cd
@set pth=!cd!
@set suf=%1
for /f "skip=2 tokens=5,9" %%i in (list.txt) do @call set src="%pth%\%%j.%%1" &&@call set des="%pth%%%i" &&@call out.bat %%src%% %%des%%
@endlocal
out.bat内容:
xcopy /f %~dpnx1 %~dpnx2
命令行运行:bat-out.bat out
屏幕回显:
D:\UI>xcopy /f D:\UI\script\78F8C5ED.out D:\UI\script\script\task\target\usertrackinfo.lua
目标 D:\UI\script\script\task\target\usertrackinfo.lua 是文
件名
还是目录名
(F = 文件,D = 目录)? f
D:\U-Disk\TMP\JXSJ_Pak\out\script\78F8C5ED.out -> D:\U-Disk\TMP\JXSJ_Pak\out\scr
ipt\script\task\target\usertrackinfo.lua
复制了 1 个文件
分析:
out.bat的参数传递有问题。
通过修改out.bat为回显参数:
@echo bgin
@echo %~1
@echo ,
@echo %~2
屏幕显示正确传递,但现在参数变量的格式不正确。即:不能将%1、%2传递参数设置为Xcopy 正确的源文件,目标文件
官方解释为:
说明
目标的默认值
如果省略目标,xcopy 命令将文件复制到当前目录。
指定目标是文件还是目录
如果目标不包含现存的目录,并且不以反斜杠 (\) 结尾,xcopy 将显示下列格式的提示消息:
Does destination specify a file name
or directory name on the target
(F = file, D = directory)?
如果要将一个或多个文件复制到一个文件,请按 F。如果要将一个或多个文件复制到一个目录,请按 D。
使用 /i 开关可以避免该提示。如果使用了 /i 开关,如果源是多个文件或目录,xcopy 将假定目标为目录。
Last edited by apareon on 2009-11-28 at 13:51 ]
The export format of PAK files in the game is:
The CRC32 checksum of the file.out
For example:
ui\0147E5A6.out
There is a file storing the original file name list.txt, (due to the post reason, it is not clear, between each column in each row is TAB separated, and between the time items (2009-6-30 15:22:1) is space separated) The format is:
TotalFile:768 PakTime:2009-11-11 11:13:40 PakTimeSave:4afa2be4 CRC:3f91d323
Index ID Time FileName Size InPakSize ComprFlag CRC
0 6bf9d 2009-6-30 15:22:1 \ui\script\window\playerstate.lua 5108 1834 4 4aecede2
1 5e0d8d 2008-10-24 10:1:21 \ui\001a\window\blogviewplayer.ini 9241 1806 4 71579ab8
2 c8f97d 2009-9-23 17:50:16 \ui\001a\worldmap\npcsetting\1622.txt 109 104 4 c461871a
Now we need to rename the source file to the target file.
The file name of the source file is the value of the last column of list.txt, which is CRC, with the suffix.out.
The target file is the value of the fourth column, Filename, in list.txt.
For example:
c461871a.out is renamed to \ui\001a\worldmap\npcsetting\1622.txt
I'm a newbie and tried to write it with FOR myself but didn't succeed.
Please ask the experts, and use batch processing to rename, thank you!
=======================
Current directory: D:\UI
list.txt
The ninth column is the source file name (note that the source file name here does not have the suffix:.out)
The fifth column is the target file name
【Idea】Use FOR, extract the ninth column (source file name without suffix, 4aecede2) in the list.txt file, modify it to the complete source file name (for example: D:\UI\4aecede2.out), and use Xcopy to rename it to the target file name pointed to by the fifth column (for example: D:\UI\ui\script\window\playerstate.lua)
=======================
Test record
I did it myself, for reference:
for /f "skip=2 tokens=5,9" %i in(list.txt) do command
skip=2 Skip the first two lines
tokens=5 Take the target file path
tokens=9 Take the source file name
command Execute the command, rename the source file name to the target file name xcopy %i.out %j
I'll go test it...
Error: %i gets the file name, without the suffix, how to make it %i.out like the full file name?
2009-11-23 20:30 modification test:
Batch processing:
for /f "skip=2 tokens=5,9" %%i in (list.txt) do set var=%%j set de=%%i
Display:
set var=47f384bb
set de=\script\event\zhongqiu_jieri\200809\item\canghaiyueming.lua
Currently, the parameters can be obtained, but the var variable (for example: 47f384bb) cannot be changed to the source file name (for example: 47f384bb.out)
2009-11-24 2:30 modification test:
Current directory:D:\UI
Command line operation:D:\UI>bat-out.bat out
Content of batch processing file bat-out.bat:
@setlocal ENABLEDELAYEDEXPANSION
@cd
@set pth=!cd!
@set suf=%1
for /f "skip=2 tokens=5,9" %%i in (list.txt) do call out.bat %pth% %%j %suf% %%i
@endlocal
Content of batch processing file out.bat:
xcopy /f %~dp1%~n2%~x3 %~f4
Command line echo content:
D:\UI>call out.bat D:\UI\script
ddecb8c2 out \script\event\jieri\200812_xmas\item\xmas_giftbox.lua
D:\UI>xcopy /f D:\UI\ddecb8c2 D:\UI\scriptevent\jieri\200812_xmas\item\xmas_giftbox.lua
File not found - ddecb8c2
0 file(s) copied
Analysis:
When CALL batch processing, the suf environment variable value is correct, but when passed to out.bat, that is: the passed parameter %3 does not become %~x3, that is, it becomes the suffix of the file, so xcopy cannot find the file.
Hey, I can't solve it myself, please help me, thank you!
2009-11-26 21:16 modification test:
Content of bat-out.bat:
@setlocal ENABLEDELAYEDEXPANSION
@cd
@set pth=!cd!
@set suf=%1
for /f "skip=2 tokens=5,9" %%i in (list.txt) do @call set src="%pth%\%%j.%%1" &&@call set des="%pth%%%i" &&@call out.bat %%src%% %%des%%
@endlocal
Content of out.bat:
xcopy /f %~dpnx1 %~dpnx2
Command line operation: bat-out.bat out
Screen echo:
D:\UI>xcopy /f D:\UI\script\78F8C5ED.out D:\UI\script\script\task\target\usertrackinfo.lua
Target D:\UI\script\script\task\target\usertrackinfo.lua is a file name
Or a directory name
(F = file, D = directory)? f
D:\U-Disk\TMP\JXSJ_Pak\out\script\78F8C5ED.out -> D:\U-Disk\TMP\JXSJ_Pak\out\scr
ipt\script\task\target\usertrackinfo.lua
1 file(s) copied
Analysis:
There is a problem with the parameter passing of out.bat.
By modifying out.bat to echo parameters:
@echo bgin
@echo %~1
@echo ,
@echo %~2
The screen displays correct passing, but now the format of the parameter variable is incorrect. That is, the %1, %2 passed parameters cannot be set to the correct source file and target file for Xcopy.
Official explanation:
Description
Default value for destination
If destination is omitted, the xcopy command copies files to the current directory.
Specify whether destination is a file or directory
If destination does not contain an existing directory and does not end with a backslash (\), the xcopy command displays a prompt message in the following format:
Does destination specify a file name
or directory name on the target
(F = file, D = directory)?
Press F if you want to copy one or more files to a file. Press D if you want to copy one or more files to a directory.
The /i switch can be used to avoid this prompt. If the /i switch is used, xcopy assumes the destination is a directory if the source is one or more files or directories.
Last edited by apareon on 2009-11-28 at 13:51 ]
|