Vpk.exe: Difference between revisions
Jump to navigation
Jump to search
(→Multi-chunk files: Added relative path example) |
No edit summary |
||
Line 1: | Line 1: | ||
'''VPK''' ("Valve Pak") files are uncompressed archives used to package content | '''VPK''' ("Valve Pak") files are uncompressed archives used to package game content. Valve's post-[[GCF]] games store [[VMT|material]]s, [[MDL|model]]s, [[particles]], and [[VCD|choreography scenes]] in VPK files. VPK is also used to distribute mods via the the <code>addoninstaller</code> tool that ships with some games. | ||
== | == Creation == | ||
VPKs can be created with the [[command line]] tool <code>vpk.exe</code> | VPKs can be created with the [[command line]] tool <code>vpk.exe</code>. | ||
=== Commands === | === Commands === | ||
; <code><dirname></code> | ; <code><dirname></code> | ||
: Creates a | : Creates a VPK containing the contents of the given directory. Must be an existing location. The VPK will appear next to the directory. {{tip|Drag a folder onto the tool in Explorer to trigger this command.}} | ||
; <code>x <vpkfile> <filename1> <filename2> ...</code> | ; <code>x <vpkfile> <filename1> <filename2> ...</code> | ||
: Extract file(s). | : Extract file(s). | ||
Line 16: | Line 14: | ||
: Add file(s). | : Add file(s). | ||
; <code>a <vpkfile> @<filename></code> | ; <code>a <vpkfile> @<filename></code> | ||
: Adds the files referenced in a "response file" (''not'' response rules). Note the <code>@</code> symbol. | |||
; <code>k vpkfile <filename></code> | ; <code>k vpkfile <filename></code> | ||
: Add files | : Add files references in a [[keyvalues]] file. {{bug|They will appear inside the VPK with their full path (<code>C:\etc\</code>) intact - is there a way to avoid this?}} | ||
; <code>l <vpkfile></code> | ; <code>l <vpkfile></code> | ||
; <code>L <vpkfile></code> | ; <code>L <vpkfile></code> | ||
Line 24: | Line 23: | ||
: Verbose output. | : Verbose output. | ||
; <code>-M</code> | ; <code>-M</code> | ||
: Produce a multi-chunk VPK | : Produce a multi-chunk VPK. | ||
:* Each chunk is a file limited to around 200MB. | |||
:* To reduce patch sizes, chunks are never overwritten. New/modified files are instead written to a brand new chunk every time you run the tool. {{note|Multi-chunk generations only works when creating a VPK from a response file.}}{{tip|To inspect a multi-chunk VPK open the '_dir' file.}} | |||
=== Response file === | |||
A "response file" contains a list of files to be added to a VPK. Paths are relative to the current directory of the <code>vpk</code> tool. | |||
Below is a Python script which generates a response file and then builds a multi-chunk VPK. Put it in your mod folder. You will need to edit the three variables at the top. | |||
<source lang="python"> | |||
# User settings (don't use the \ character) | |||
target_folders = [ "materials", "models", "particles", "scenes" ] | |||
file_types = [ "vmt", "vtf", "mdl", "phy", "vtx", "vvd", "pcf", "vcd" ] | |||
vpk_path = "C:/Program Files (x86)/Steam/steamapps/common/SourceFilmmaker/game/bin/vpk.exe" | |||
# Script begins | |||
import os,subprocess | |||
from os.path import join | |||
response_path = join(os.getcwd(),"vpk_list.txt") | |||
out = open(response_path,'w') | |||
len_cd = len(os.getcwd()) + 1 | |||
for user_folder in target_folders: | |||
for root, dirs, files in os.walk(join(os.getcwd(),user_folder)): | |||
for file in files: | |||
if len(file_types) and file.rsplit(".")[-1] in file_types: | |||
out.write(os.path.join(root[len_cd:].replace("/","\\"),file) + "\n") | |||
out.close() | |||
subprocess.call([vpk_path, "-M", "a", "pak01", "@" + response_path]) | |||
</source> | |||
=== Excluded files === | |||
Executable and archive files are discarded by the VPK tool: | |||
.zip .reg .rar .msi .exe .dll .com .cmd .bat | |||
== See also == | == See also == |
Revision as of 09:32, 16 September 2012
VPK ("Valve Pak") files are uncompressed archives used to package game content. Valve's post-GCF games store materials, models, particles, and choreography scenes in VPK files. VPK is also used to distribute mods via the the addoninstaller
tool that ships with some games.
Creation
VPKs can be created with the command line tool vpk.exe
.
Commands
<dirname>
- Creates a VPK containing the contents of the given directory. Must be an existing location. The VPK will appear next to the directory.
Tip:Drag a folder onto the tool in Explorer to trigger this command.
x <vpkfile> <filename1> <filename2> ...
- Extract file(s).
a <vpkfile> <filename1> <filename2> ...
- Add file(s).
a <vpkfile> @<filename>
- Adds the files referenced in a "response file" (not response rules). Note the
@
symbol. k vpkfile <filename>
- Add files references in a keyvalues file.
Bug:They will appear inside the VPK with their full path (
C:\etc\
) intact - is there a way to avoid this? [todo tested in ?] l <vpkfile>
L <vpkfile>
- List contents of VPK. Uppercase 'L' means more detail.
-v
- Verbose output.
-M
- Produce a multi-chunk VPK.
- Each chunk is a file limited to around 200MB.
- To reduce patch sizes, chunks are never overwritten. New/modified files are instead written to a brand new chunk every time you run the tool.
Note:Multi-chunk generations only works when creating a VPK from a response file.
Tip:To inspect a multi-chunk VPK open the '_dir' file.
Response file
A "response file" contains a list of files to be added to a VPK. Paths are relative to the current directory of the vpk
tool.
Below is a Python script which generates a response file and then builds a multi-chunk VPK. Put it in your mod folder. You will need to edit the three variables at the top.
# User settings (don't use the \ character)
target_folders = [ "materials", "models", "particles", "scenes" ]
file_types = [ "vmt", "vtf", "mdl", "phy", "vtx", "vvd", "pcf", "vcd" ]
vpk_path = "C:/Program Files (x86)/Steam/steamapps/common/SourceFilmmaker/game/bin/vpk.exe"
# Script begins
import os,subprocess
from os.path import join
response_path = join(os.getcwd(),"vpk_list.txt")
out = open(response_path,'w')
len_cd = len(os.getcwd()) + 1
for user_folder in target_folders:
for root, dirs, files in os.walk(join(os.getcwd(),user_folder)):
for file in files:
if len(file_types) and file.rsplit(".")[-1] in file_types:
out.write(os.path.join(root[len_cd:].replace("/","\\"),file) + "\n")
out.close()
subprocess.call([vpk_path, "-M", "a", "pak01", "@" + response_path])
Excluded files
Executable and archive files are discarded by the VPK tool:
.zip .reg .rar .msi .exe .dll .com .cmd .bat