Changing File Case


Change the case of a file on a Perforce Server.


The solution to changing the case of files depends on the native case-handling behavior of your platform. For platforms with case-sensitive file systems (for example, Linux), the case change operation is a straightforward rename. On Windows, additional steps have to be taken to account for the fact that the NTFS file system largely ignores case differences; it is case-aware, but case-insensitive.


Because Windows uses a case-insensitive file system, references to files that differ only by case are ignored. In order to get the Perforce Server to change the case of a file on a Windows Server, the file must first be deleted and then re-added to Perforce using the correct case. Additionally, the internal Perforce "have list" references to the old case name must be eliminated by removing the file from case-insensitive workspaces and then re-syncing the file using the correct case.

Windows Example

In this example, file "foo" has three revisions and you want to change the file name to use all upper-case, from "foo" to "FOO".

  1. Delete the existing file
    p4 delete foo
    p4 submit
  2. Recreate the file in your local file system with the correct case. Then, use the p4 sync command to re-create the file in your workspace using the correct case.
    p4 sync FOO#3
  3. Remove the internal "have list" reference. The p4 flush command (sync -k, in recent versions) removes the have list reference without removing the file from your workspace.
    p4 flush FOO#none
  4. Re-add the file in the correct case. As with the sync command, the p4 add command uses the case of the file argument provided at the command line, so it is important to provide the correct case.
    p4 add FOO
    p4 submit


To obtain the newly case-changed file, all users who use workspaces on case-insenstive file systems (such as Windows NTFS or MacOS X HFS) must remove the old file from their workspace and then re-sync the renamed file with the correct case to replace it in their workspace.

For the example above, this means:

  1. p4 sync foo#none
  2. p4 sync FOO#head

Unix (and case-sensitive platforms)

On Unix, simply integrate the file and delete the original file.

Unix example

  1. Use p4 integrate to change the old name to the new name.
    $ p4 integrate kiwi.txt Kiwi.txt
    //depot/Kiwi.txt#1 - branch/sync from //depot/kiwi.txt#1,#9
  2. Delete the original name.
    $ p4 delete kiwi.txt
    //depot/kiwi.txt#9 - opened for delete
  3. Submit the changes.
    $ p4 submit
    Change 12681 created with 2 open file(s).
    Submitting change 12681.
    Locking 2 files ...
    branch //depot/Kiwi.txt#1
    delete //depot/kiwi.txt#10
    Change 12681 submitted.

Verify the results

Use the p4 files command to check that the Perforce metadata is in the proper case.

$ p4 files Kiwi.txt
//depot/Kiwi.txt#1 - branch change 12681 (text)

Note that "Kiwi.txt" is now in the proper case.