Removing old versions

Build 1501 on 14/Nov/2017  This topic last edited on: 1/Sep/2014, at 15:50

The removersions command is used to remove objects versions.

See removeversions (cmd4 command) or removeversions (srv4 command)

To remove versions in a specified date time range

Use the arguments "from" and "to".

This command will remove all the versions for the given objects from 01/01/2009 to 05/01/2009

cmd4 removeversions -ids 2393,2394 -from 2009-01-01T00:00:00 -to 2009-01-05T23:59:59 -userName xxxx -password yyyy

where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.

Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.

You can use timestamp as arguments, specifying milliseconds like this:

cmd4 removeversions -ids 2393,2394 -from 2009-01-01T13:02:00.5600 -to 2009-01-05T21:15:00.6200 -userName xxxx -password yyyy

where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.

Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.

You can also use "from" or "to" without specifying a range.

This command will remove all the versions for the given objects after 01/01/2009 00:00:00:

cmd4 removeversions -ids 2393,2394 -from 2009-01-01T00:00:00 -userName xxxx -password yyyy

where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.

Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.

This command will remove all the versions for the given objects before 01/01/2009 00:00:00:

cmd4 removeversions -ids 2393,2394 -to 2009-01-01T00:00:00 -userName xxxx -password yyyy

where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.

Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.

To limit versions to be removed

You can limit the number of versions that will be deleted using the argument "limitremove".

This command will remove all the versions for the given objects after 01/01/2009 00:00:00, but it will delete a maximum of 3 versions:

cmd4 removeversions -ids 2393,2394 -from 2009-01-01T00:00:00 -limitremove 3 -userName xxxx -password yyyy

where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.

Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.

Removing versions by number

To remove versions by number you can use the arguments "fromversion" and "limitremove".

fromversion

The "fromversion" argument represents the version from which start to remove.

If the "fromversion" argument is a positive number, the version count starts from the oldest to the newest (so that version 1 is the oldest).

If it is a negative number, the version count will start from the newest to the oldest (so that version -1 is the newest version).

limitremove

The "limitremove" argument (as in combination with "from" and "to"), limits the number of versions that will be removed.

This command will remove the 2 oldest version of the given objects (version 1 and 2):

cmd4 removeversions -ids 2393,2394 -fromversion 1 -limitremove 2 -userName xxxx -password yyyy

This command will remove the 2 newest version of the given objects:

cmd4 removeversions -ids 2393,2394 -fromversion -1 -limitremove 2 -userName xxxx -password yyyy

You can also use the "from"/"to" and "fromversion"/"limitremove" arguments together.

In this case the version count will start from the given "from" argument, version 1 will be the first version found after the given "from" argument, and version -1 will be the last version found before the "to" argument.

This command will remove all versions of the day 01/01/2009 except the last 2 versions of that day:

cmd4 removeversions -ids 2393,2394 -from 2009-01-01T00:00:00 -to 2009-01-01T23:59:59 -fromversion -3 -userName xxxx -password yyyy

Notes

All the above examples with cmd4 connect to the default connection: should you want to specify the connection or server, see cmd4 examples.

Replace xxxx with the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy with the password.