Checking in changes prior to tagging of version 2.30.
[MogileFS-Utils.git] / mogrename
bloba9133fce2153dbc8c8ecc9279b5b9280aaab8240
1 #!/usr/bin/perl
3 =head1 NAME
5 mogrename -- Rename file (key) from one key to another
7 =head1 SYNOPSIS
9 $ mogrename [OPTIONS] --old_key='/hello.jpg' --new_key='/bye.jpg'
11 $ mogupload --trackers=host --domain=foo --class=bar \
12 --old_key='/hello.jpg' --new_key='/bye.jpg'
14 $ mogupload --trackers=host1:7001,host2:7001 --domain=foo --class=bar \
15 --old_key='/hello.jpg' --new_key='/bye.jpg'
17 =head1 OPTIONS
19 =over
21 =item --trackers=host1:7001,host2:7001
23 Use these MogileFS trackers to negotiate with.
25 =item --domain=<domain>
27 Set the MogileFS domain to use.
29 =item --class=<class>
31 Set the class to use. Will use default class if not specified.
33 =item --old_key='<old key>'
35 An old key to rename the file from. Can be an arbitrary string.
37 =item --new_key='<new key>'
39 A new key to rename the file to. Can be an arbitrary string.
41 =back
43 =head1 AUTHOR
45 Krzysztof Wilczynski E<lt>L<krzysztof.wilczynski@linux.com>E<gt>
47 =head1 BUGS
49 None for this release. Please report any issues found.
51 =head1 LICENSE
53 Licensed for use and redistribution under the same terms as Perl itself.
55 =cut
57 use strict;
58 use warnings;
60 use lib './lib';
61 use MogileFS::Utils;
63 my $utils = MogileFS::Utils->new;
65 my $usage = "--trackers=host --domain=foo --class=bar "
66 . "--old_key='/hello.jpg' --new_key='/bye.jpg'";
68 my $options = $utils->getopts($usage, qw(old_key=s new_key=s));
70 my $mogile_client = $utils->client;
72 $mogile_client->rename($options->{'old_key'}, $options->{'new_key'});
74 if ($mogile_client->errcode) {
75 die "Error renaming file (key) from " . $mogile_client->errstr;