Vpk.exe

VPK (Valve Pak) files are uncompressed archives used to package game content, first introduced in , later backported during SteamPipe update. Valve's post GCF games store materials, models, particles, choreography scenes and many other file types in VPK files. Executable and some archive files are discarded by vpk.exe: .zip, .reg, .rar, .msi, .exe, .dll, .com, .cmd and .bat. Some third-party games (even using an engine as old as ) can load depot VPK files as long as Steam is running.
VPKs are also used to distribute mods via the the addoninstaller tool that ships with some games, such as .
VPKs can be created with the command line tool vpk.exe.
= VPK.exe =
== Creation ==
The tool can be located in the bin folders for most Source games, such as the ones below. The tool is not game dependent, however it is suggested that you use the tool that corresponds to the game you are creating the vpk for. The version in one game may not be as up to date as the version in another due to game updates.
 Game	 Path to VPK.exe 	Version
 	..\steamapps\common\Alien Swarm\bin 	v1
 	..\steamapps\common\Counter-Strike Source\bin 	v2
 	..\steamapps\common\Counter-Strike Global Offensive\bin 	v2
 	..\steamapps\common\Left 4 Dead\bin 	v1
 	..\steamapps\common\Left 4 Dead 2\bin 	v1
 	..\steamapps\common\Portal 2\bin 	v1
 	..\steamapps\common\Source SDK Base 2013\<Singleplayer or Multiplayer>\bin	v2
 	..\steamapps\common\Team Fortress 2\bin 	v2
For servers installed using SteamCMD, it is located in the server's bin\ directory. On Linux, it is named vpk_linux32 instead of vpk.exe.
=== Linux / Unix ===
Note: The vpk binary makes VPK files of version 2.0, which are not compatible with games like that use an older version of the VPK format (in fact will not even start if it detects an unsupported vpk). There is a Python package that can be installed with pip install vpk which supports the older format. It is also far more convenient than using the built-in tool. Instructions can be found on the Github page. 
On Linux / Unix clients, the vpk file can be found replacing "..\steamapps\common" for "~/.steam/steam/steamapps/common/". However, it is named vpk_linux32 instead of vpk.exe. Note: If you installed Steam via Flatpak, the path is slightly different. Look in ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common
If you are running on a 64-bit system, this binary will not work by default. You must tell it to use the 32-bit libraries located in the same directory. This can be done by setting the LD_LIBRARY_PATH variable.
The following script, if created in the above listed bin directories, will create a wrapper to properly launch the 32-bit executable; then a link (or desktop shortcut) to vpk.sh (if saved as said name) can be created, from there:
#!/bin/bash
DIR=$(dirname "${BASH_SOURCE[0]}")
export LD_LIBRARY_PATH=$(cd "$DIR" && pwd)
exec "$DIR/vpk_linux32" "${@}"
Alternatively, if you're running 64-bit Linux, you can use this script to execute the vpk_linux32 binary successfully. Save this script to "/usr/local/bin/vpk" and set it as an executable in the file's properties, for ease of use:
#!/bin/bash
VPK_LINUX=$(find "${HOME}/.local/share/Steam" -type f -iname "vpk_linux32" -print | head -n 1)
VALVE_LIB_DIR=$(dirname "${VPK_LINUX}")
LD_LIBRARY_PATH="${VALVE_LIB_DIR}:${LD_LIBRARY_PATH}" "${VPK_LINUX}" "${@}"
HELPFUL NOTE: The "${@}" is for drag-and-drop with *.desktop files and arguments when using the vpk command via console.
=== Windows ===
On Windows, you can easily drag-and-drop folders onto vpk.exe file in the bin folder and get a *.vpk file in return, and vice-versa by drag-and-dropping a *.vpk file instead.
== Commands ==
==== Usage ====
::vpk [options] <directory>
::vpk [options] <vpkfile>
::vpk [options] <command> <command arguments...>
==== Example ====
::vpk -?
:; Lists all of the help info, list of available arguments, and info about each argument.
=== Create VPK/Add Files ===
; vpk <directory>
: Create VPK from directory structure. Must be an existing location. The VPK will appear next to the directory. 
; vpk a <vpkfile> <filename1> <filename2> ...
: Add file(s).
; vpk a <vpkfile> @<filename>
: Adds the files referenced in a "response file" (not response rules). Note the @ symbol.
: The added file will not be added with its file path if the default file path matches that of CMD
; vpk k <vpkfile> <keyvalues_filename>
: Add files references in a keyvalues control file. 
=== Extract Files ===
; vpk <vpkfile>
: Extract all files from VPK. 
; vpk x <vpkfile> <filename1> <filename2> ...
: Extract file(s). 
=== Display VPK Info ===
; vpk l <vpkfile>
: List contents of VPK.
; vpk L <vpkfile>
: List Detailed contents of VPK.
=== VPK Integrity/Security ===
; vpk checksig <vpkfile>
: Verify signature of specified VPK file. Requires -k to specify key file to use.
== Misc. ==
; vpk generate_keypair <keybasename>
: Generate public/private key file. Output files will be named <keybasename>.publickey.vdf and <keybasename>.privatekey.vdf 
=== Options ===
; 
; -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. 
; -P
: Use SteamPipe-friendly incremental build algorithm. Use with 'k' command. For optimal incremental build performance, the control file used for the previous build should exist and be named the same as theinput control file, with '.bak' appended, and each file entryshould have an 'md5' value. The 'md5' field need not be theactual MD5 of the file contents, it is just a unique identifierthat will be compared to determine if the file contents has changedbetween builds.
; -c <size>
: Use specified chunk size (in MB). Default is 200.
; -a
: Align files within chunk on n-byte boundary. Default is 1.
; -K
: With commands 'a' or 'k': Sign VPK with specified private key.
; -k
: With commands 'a' or 'k': Public key that will be distributed and used by third parties to verify signatures.
: With command 'checksig': Check signature using specified key file.
== Examples ==
Listed below are some examples of using the tool and what they will do.
==Creating your own VPKs for a mod==
Your mod's assets must be packaged within the appropriate content folders ("sound," "materials," "models," etc.) in the root directory of your VPK. Otherwise you won't be able to see or use your assets in Hammer!
For a specific example, imagine you're packing the content for your mod called "MyMod," and want to include a sound .wav named "ocean_ambient.wav". In your MyMod folder to be packed, you would probably want to place ocean_ambient.wav under "MyMod/sound/", or better, in a specific subdirectory of that one, like "MyMod/sound/ambient/". The same principle is easily applied to other assets like compiled model files, or materials and textures. These would be best placed in subdirectories of "MyMod/models" and "MyMod/materials", respectively.
VPKs must be mounted in gameinfo.txt.
===Creating A Key Value File and VPK===
:1. Create a folder with the correct directory structure and files that you wish to use such as MyMod/resource/ui/<file.res>
:2. Use the command line in a prompt or a bat: 
::vpk generate_keypair <name>
::vpk -M -k <name>.publickey.vdf -K <name>.privatekey.vdf "..\SteamApps\common\Team Fortress 2\bin\MyMod"
:3. In the folder where the VPK tool is located there will now be a public key VDF, a private key VDF, a VPK named mymod_000 and a VPK named mymod_dir. 
::
::* You must distribute your mod with both the mymod_dir and mymod_000 VPKs for the keyvalue to work.
== 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.
#What folders to look for, and pack into the pak01 vpk set.
target_folders = [ "materials", "models", "resource", "media", "particles", "scripts", "maps", "expressions", "scenes" ]
#What files to look for, in the aforementioned folders.
file_types = [ "vmt", "vtf", "mdl", "phy", "vtx", "vvd", "ani", "pcf", "vcd", "txt", "res", "vfont", "cur", "dat" , "bik", "mov", "bsp", "nav", "lst", "lmp", "vfe" ]
#which vpk.exe to use. do not use \!
vpk_path = "../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()
#the "pak01" here specifies the multi-chunk vpk names. Could be changed to "pak02" or "hl2_textures", or whatever your mod needs.
subprocess.call([vpk_path, "-M", "a", "pak01", "@" + response_path])
To handle this process for you can also use the P2 Multichunk Tool, to automate the response file creation and the creation of the vpk files.
::
=== Excluded files ===
Executable and some archive files are discarded by the VPK tool:
.zip .reg .rar .msi .exe .dll .com .cmd .bat
= See also =
* VPK File Format (technical details)
* L4D Campaign Add-on Tutorial
* L4D2 Campaign Add-on Tutorial
* Releasing A Portal 2 Map
* P2 Multichunk Tool (Easy handling of mass vpk packing)
* Swarm Campaign Add-on Tutorial
* VPK Compare GUI Tool for finding conflicts between VPK files 
* Source Multi-Tool (VPK Creator - GUI)
* Fixing VPK mounting for older Source SDK Bases (for & )
=== Software ===
* - Program which can create and modify VPK files (supports both VPK v1 and v2, aswell as VPK format)
* - Program which modify VPK files, since GCFScape 1.7.1 (supports both VPK v1 and v2, no longer updated)
Category:Modding
Category:Steam 
category:File formats