Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 Server Administration Documentation | 2026.1

# Define filetypes with p4 typemap

By default, P4 Server has a way of automatically deciding whether a file is text or binary when it adds the file to the depot. You can customize this behavior. It is also possible to change the filetype for a file already in the depot.

## Default typemap

P4 Server uses the `filesys.binaryscan` configurable to determine how many bytes to examine when determining if a file is of type `text` or `binary`. By default, `filesys.binaryscan` is 65536. If the high bit is clear in the first 65536 bytes, P4 Server assumes it to be `text`. Otherwise, it is assumed to be `binary`.

Files compressed in the `.zip` format, including `.jar` files, are also automatically detected and assigned the type `binary+F`, where +F is a file type modifier. To learn more, see File type modifiers in P4 CLI Reference.

Filetype detection is usually correct. However there might be exceptions or different user requirements. For example, RTF (Rich Text Format) and Adobe PDF (Portable Document Format) can start with a series of comment fields or other textual data. If these comments are sufficiently long, such files can be erroneously detected by the P4 Server as being of type text.

## Change the default filetype detection

To change the default filetype detection, create a typemap with the `p4 typemap` command. This command enables you to map P4 Server file types to file specifications defined in depot syntax The syntax for specifying the location of files in the P4 Server depot as opposed to in the user's client workspace. Depot syntax begins with //depotName/. When a file is being added and it matches a mapping in the typemap table, the corresponding filetype is assigned. Definitions for the typemap are applied to new files being added.

To change the filetype for files that were already added before you created the mapping table or for files you are currently adding, see Specify the filetype at the command line.

For example, to treat zip and jar files as `binary` instead of binary+F, use `p4 typemap` to modify the typemap table:

Copy

    1
    2
    3
    4
    Typemap:
            binary //....zip
            binary //....jar
            binary+w //...user-lib...

The first three periods (...) in the specification are a P4 Server wildcard specifying all files in all depots are to be included in the mapping.

In lines 2 and 3, the fourth period and the file extension specify that files with the .zip or .jar extension are mapped to binary.

Line 4 specifies that any file with user-lib in its name or path be assigned binary+w as its filetype.

To learn more, see Wildcards in P4 CLI Reference.

## Common file extensions

Consider these P4 Server file types and modifiers for common file extensions:

File type | P4 Server file type | Description
--- | --- | ---
`.asp` | `text` | Active server page file.
`.avi` | `binary+F` | Video for Windows file.
`.bmp` | `binary` | Windows bitmap file.
`.btr` | `binary` | Btrieve database file.
`.cnf` | `text` | Conference link file.
`.css` | `text` | Cascading style sheet file.
`.docx` | `binary` | Microsoft Word document.
`.dotx` | `binary` | Microsoft Word template.
`.exp` | `binary+w` | Export file or Microsoft Visual C++
`.gif` | `binary+F` | GIF graphic file.
`.gz` | `binary+F` | Gzip compressed file.
`.htm` | `text` | HTML file.
`.html` | `text` | HTML file.
`.ico` | `binary` | Icon file.
`.inc` | `text` | Active Server include file.
`.ini` | `text+w` | Initial application settings file.
`.jpg` | `binary` | JPEG graphic file.
`.js` | `text` | JavaScript language source code file.
`.lib` | `binary+w` | Library file.
`.log` | `text+w` | Log file.
`.mpg` | `binary+F` | MPEG video file.
`.pdf` | `binary` | Adobe PDF file.
`.pdm` | `text+w` | SAP Power Designer file.
`.pptx` | `binary` | Microsoft PowerPoint file.
`.prefab` | `binary` | Unity3D file.
`.xlsx` | `binary` | Microsoft Excel file.

## Example typemap

Use the following `p4 typemap` table to map file extensions to the P4 Server file types recommended in the preceding table.

Copy

    # Perforce File Type Mapping Specifications.
    #
    #  TypeMap:     a list of filetype mappings; one per line.
    #               Each line has two elements:
    #               Filetype: The filetype to use on 'p4 add'.
    #               Path:     File pattern which will use this filetype.
    # See 'p4 help typemap' for more information.
    TypeMap:

            text //....asp
            binary+F //....avi
            binary //....bmp
            binary //....btr
            text //....cnf
            text //....css
            binary //....docx
            binary //....dotx
            binary+w //....exp
            binary+F //....gif
            binary+F //....gz
            text //....htm
            text //....html
            binary //....ico
            text //....inc
            text+w //....ini
            binary //....jpg
            text //....js
            binary+w //....lib
            text+w //....log
            binary+F //....mpg
            binary //....pdf
            text+w //....pdm
            binary //....ppt
            binary //....xlsx

If a file type requires the use of more than one file type modifier, specify the modifiers consecutively. For example, `binary+lFS10` refers to a `binary` file with exclusive-open (`l`), stored in full (`F`) rather than compressed, and for which only the most recent ten revisions are stored (`S10`).

## Specify the filetype at the command line

Regardless of whether you have set up your own typemap or not, you might want to change the filetypes of files that have already been added to the depot. You also might want to manually add files with a different filetype than would occur otherwise.

To override the default filetype detection when opening a file for add, use:

p4 add -t

or

p4 reopen -t

To change the filetype for existing files, use:

p4 edit -t

or

p4 reopen -t

To learn more, see File type modifiers in P4 CLI Reference, which also provides additional information about
Overriding file type with the -t option.

Your search for returned results