Purging from the command line

If you create a Purge XML file, you can purge from the command line and schedule purging tasks.


<?xml version="1.0"?>
<XML>
  <Settings>
    <LoggingDirectory>C:\Temp</LoggingDirectory>
    <LogFilePrefix>Purge_</LogFilePrefix>
    <Items Purge="true">
      <Keep>1</Keep>
      <DaysToKeep>0</DaysToKeep>
      <Recursive>1</Recursive>
    </Items>
    <ProcessHistories Purge="true" Before="1999-12-23"/>
    <PublishTransactions Purge="false" Before="2006-05-04">
      <State Purge="true">Success</State>
      <State Purge="true">Failed</State>
    </PublishTransactions>
  </Settings>
  <Scan>
    <Root Purge="True"/>
    <Entry URI="tcm:0-5-1" Purge="True">
      <![CDATA[ASP-Javascript-Slave]]>
    </Entry>
    <Entry URI="tcm:5-3-4" Purge="True"><![CDATA[root]]></Entry>
    <Entry URI="tcm:5-2-2" Purge="True"><![CDATA[Building Blocks]]>
    </Entry>
    <Entry URI="tcm:5-4-2" Purge="True"><![CDATA[F1]]></Entry>
    <Entry URI="tcm:0-7-1" Purge="True"><![CDATA[Publication A]]></Entry>
    <Entry URI="tcm:7-3-4" Purge="True"><![CDATA[root]]></Entry>
    <Entry URI="tcm:7-2-2" Purge="True"><![CDATA[Building Blocks]]></Entry>
    <Entry URI="tcm:2-4-2" Purge="True"><![CDATA[F1]]></Entry>
  </Scan>
</XML>

The XML file provides instructions about the purge action and may contain the following parameters for the Purge action:

ElementDescription
Logging DirectoryThe location of the output log directory.
LogFile PrefixThe prefix of the log file; for example, purge_
Items

This element has one attribute: Purge , where True = items will be purged, False = items will not be purged.

The Items element has the following sub-elements:

Keep
The number of most recent versions to keep. Note that the original version and the current version are always kept. This is a numeric value.
CutOffDate
The date before which all versions are purged.
DaysToKeep
Versions created during the specified number of day from now (backward) are kept. This option is only available from the command line and cannot be used from the Purge Tool interface. This is a numeric value.
Recursive
Determines if nested organizational items are selected, where 0 = false, and 1 = true. If true, when a parent node is selected, then child nodes are selected based on the selection of the parent node.
Process History

This element determines if Workflow Process Histories are to be purged. This element has the following attributes:

Purge
This attribute determines if Process Histories are to be purged, where True = purge, and False = do not purge.
Before
This attribute determines that date before which process histories will be purged.
Publish Transactions

This element determines if Publish Transactions are to be purged. This element has the following attributes:

Purge
This attribute determines if Process Histories are to be purged, where True = purge, and False = do not purge.
Before
This attribute determines that date before which process histories will be purged.

The PublishTransactions element also has the State subelement that determines if you are going to purge Publication Transactions successful or failed.

Entry

The Entry element determines how individual items are treated. You can use as many Entry elements as necessary.

For example:

<Entry URI=”tcm:3-5-2”
Purge=”True” Recursive=”True” KeepDate=”1-Jan-2001”>
<![CDATA[Cats & Dogs]]>
</Entry>
<Entry URI=”tcm:3-6-2”
Purge=”True” Recursive=”True” DaysToKeep=”2”>
<![CDATA[MyFolder]]>
</Entry>

Where: URI = Item URI; Purge = "True" if items in this organizational item should be purged, otherwise "False"

The Title of the item is used for display purposes only. If the text contains special XML characters (such as “&”, “?” and “/”), it must be enclosed in a <![CDATA[insert-text-here]]> section. If no special characters are present, the text can be specified without any prefixes.

Overriding the default settings