Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 76 lines (42 sloc) 1.616 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#!/usr/bin/perl

=head1 NAME

mogrename -- Rename file (key) from one key to another

=head1 SYNOPSIS

$ mogrename [OPTIONS] --old_key='/hello.jpg' --new_key='/bye.jpg'

$ mogupload --trackers=host --domain=foo --class=bar \
--old_key='/hello.jpg' --new_key='/bye.jpg'

$ mogupload --trackers=host1:7001,host2:7001 --domain=foo --class=bar \
--old_key='/hello.jpg' --new_key='/bye.jpg'

=head1 OPTIONS

=over

=item --trackers=host1:7001,host2:7001

Use these MogileFS trackers to negotiate with.

=item --domain=<domain>

Set the MogileFS domain to use.

=item --class=<class>

Set the class to use. Will use default class if not specified.

=item --old_key='<old key>'

An old key to rename the file from. Can be an arbitrary string.

=item --new_key='<new key>'

A new key to rename the file to. Can be an arbitrary string.

=back

=head1 AUTHOR

Krzysztof Wilczynski E<lt>L<krzysztof.wilczynski@linux.com>E<gt>

=head1 BUGS

None for this release. Please report any issues found.

=head1 LICENSE

Licensed for use and redistribution under the same terms as Perl itself.

=cut

use strict;
use warnings;

use lib './lib';
use MogileFS::Utils;

my $utils = MogileFS::Utils->new;

my $usage = "--trackers=host --domain=foo --class=bar "
          . "--old_key='/hello.jpg' --new_key='/bye.jpg'";

my $options = $utils->getopts($usage, qw(old_key=s new_key=s));

my $mogile_client = $utils->client;

$mogile_client->rename($options->{'old_key'}, $options->{'new_key'});

if ($mogile_client->errcode) {
    die "Error renaming file (key) from " . $mogile_client->errstr;
}
Something went wrong with that request. Please try again.