Metadata Type to Folder Structure

Use the describeMetadata call to learn the folder names of each of the types. A Java sample is included:

public void describeMetadata() {
  try {
    double apiVersion = 21.0;
    // Assuming that the SOAP binding has already been established.
    DescribeMetadataResult res =
        metadataConnection.describeMetadata(apiVersion);
    StringBuffer sb = new StringBuffer();
    if (res != null && res.getMetadataObjects().length > 0) {
      for (DescribeMetadataObject obj : res.getMetadataObjects()) {
        sb.append("***************************************************\n");
        sb.append("XMLName: " + obj.getXmlName() + "\n");
        sb.append("DirName: " + obj.getDirectoryName() + "\n");
        sb.append("Suffix: " + obj.getSuffix() + "\n");
        sb.append("***************************************************\n");
      }
    } else {
      sb.append("Failed to obtain metadata types.");
    }
    System.out.println(sb.toString());
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}

The Migration Toolkit includes a describeMetadata task that essentially uses this same code.

The documentation only describes the folder names in each element. For example, starting from Metadata Types, you can click on ApexClass, which tells us:

Declarative Metadata File Suffix and Directory Location

The file suffix is .cls for the class file. The accompanying metadata file is named ClassName-meta.xml.

Apex classes are stored in the classes folder in the corresponding package directory.


Of those I use most commonly:

type                path
ApexClass           /src/classes
ApexComponent       /src/components
ApexPage            /src/pages
ApexTrigger         /src/triggers
CustomLabel         /src/labels
StaticResource      /src/staticresources

The rest can be found in the documentation, as noted by @sfdcfox.