Perforce Public Knowledge Base - Changing the Case of a Filename
Reset Search
 

 

Article

Changing the Case of a Filename

« Go Back

Information

 
Problem

How do you change a lowercase file to a upper case and mixed case file?

Solution

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.

Windows

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. In doing so, 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 "test" has three revisions and you want to change the file name to use all upper-case, from "test" to "Test".

  1. Delete the existing file
    
    
    p4 delete test
    p4 submit -d "deleting file"
    
    
  2. Sync the file to the last non-deleted revision
Sync to the file to  before it was deleted.  Use the p4 sync command to retrieve the older version of the file from the server.
For example, if the last non-deleted revision is #3, run
 
p4 sync test#3
  1. Run p4 flush to remove the original case reference from Perforce
p4 flush test#none

The p4 flush command (also known as sync -k) removes the have list reference without removing the file from your workspace.

  1. 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 Test
  1. Submit the file
p4 submit -d "New file in mixed case"

Notes

To obtain the newly case-changed file, all userp4 flush s 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

Changing the case of a Directory

The procedure is the same:  delete, sync last version, flush, add.  Before the add, rename the directory to the desired case - you can rename it to something else then rename again to the correct case.   Do this for each file whose metadata has the incorrect directory case.

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.

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255