Deleting library item versions using the command line
An administrator can delete old versions using the command line.
This topic contains some scenarios and examples on how you can use the
delete-library-versions
command.
About this task
Imagine you have a library, containing a single item, with the following versions:
(Version number) | Name | Comment | Size | Created |
---|---|---|---|---|
(5) | 397 KB | 2022-11-05T17:29:27,841+0100 | ||
(4) | v2.0 | 404 KB | 2022-09-07T15:23:07,505+0100 | |
(3) | 999 MB | 2022-09-07T15:17:22,505+0100 | ||
(2) | v1.1 | 277 KB | 2022-08-05T14:16:28,958+0100 | |
(1) | v1.0 | Original | 108 KB | 2015-12-16T13:58:59,060+0100 |
Scenarios
See Executing commands on the command line for more details on how to use the command line.
Run the command:
delete-library-versions --user=EXAMPLE\johndoe
In the example library above, this would keep versions 5 (because it is the current version), 4 (because it has a name), 2 (because it has a name), and 1 (because it has a name and a comment). It would delete version 3 (because it does not match any of the filters used by default, which includes keeping named versions and versions with comments).
Run the command:
delete-library-versions --user=EXAMPLE\johndoe
--keep-commented-versions=false --keep-named-versions=false
--keep-smaller-than="1MB"
This would keep versions 1, 2, 4 and 5 (because these versions are all smaller than 1 MB), and delete version 3 (because it bigger than the specified size to keep).
Run the command:
delete-library-versions --user=EXAMPLE\johndoe
--keep-commented-versions=false --keep-named-versions=false
--keep-at-least=3
This would keep versions 3, 4, and 5 (because these are the three most recent versions), and delete the rest.
Run the command:
delete-library-versions --user=EXAMPLE\johndoe --keep-at-most=3
This would keep versions 5 (because it is the current version), 4 (because it has a name), and 2 (because it has a name), and delete version 3 (because it does not match any of the filters) and 1 (even though it matches two of the filters, version 1 will be dropped because there are already three more recent versions to keep).