From 6903356ad5c7d966207f41688854288e739aa2e3 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 9 Aug 2011 15:03:54 +0200 Subject: man --- videomv.pl | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 178 insertions(+), 5 deletions(-) diff --git a/videomv.pl b/videomv.pl index 8ef89ad..9c42979 100755 --- a/videomv.pl +++ b/videomv.pl @@ -41,11 +41,184 @@ videomv.pl - TODO =head1 SYNOPSIS -B TODO +B [B<--sort>] I [I<.../>{I,I}I[I]] + +video + |- ... + |- DIRECTORS + | |- director1/ + | |- director2/ + | `- ... + `- MOVIES/ =head1 DESCRIPTION +Depending on whether I is I<.../MOVIES/>, +I<.../DIRECTORS/director/>, or something +else, one has one of the six behaviors below. For the sake of +readability the paths are absolute here, but relative paths are fine as +well. + +=over 4 + +=item B [B<--sort>] I<.../MOVIES/oldfile> I<.../MOVIES/newfile> + +I is supposed to be an existing symlink in I<.../MOVIES/>, +which targets to I<../DIRECTORS/director/oldfile>. If +I=I, an error will be raised. Otherwise, the following +actions will be performed: + +=over 4 + +=item * The filename in the database will be updated, + +=item * the old target will be renamed to I<../DIRECTORS/director/newfile>, + +=item * the old symlink will be deleted, and + +=item * a new symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/director/newfile> +will be created. + +=back + +If the B<--sort> flag is set, the new I will be find on the +database instead of from the old target. + + +=item B I<.../MOVIES/oldfile> I<.../DIRECTOR/newdirector/>[I] + +I is supposed to be an existing symlink in I<.../MOVIES/>, +which targets to I<../DIRECTORS/olddirector/oldfile>. If +I=I +(or if I=I and I was not given), +an error will be raised. +Otherwise, the following actions will be performed: + +=over 4 + +=item * The filename in the database will be updated if I<>I, + +=item * the old target will be moved to I<../DIRECTORS/newdirector/newfile>, +(or to I<../DIRECTORS/newdirector/oldfile> if I was not given), + +=item * the old symlink will be deleted, and + +=item * a new symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/newdirector/newfile> +(or -> I<../DIRECTORS/newdirector/oldfile> if I was not given) +will be created. + +=back + + +=item B [B<--sort>] I<.../DIRECTORS/director/oldfile> I<.../MOVIES/newfile> + +A symlink I<.../MOVIES/oldfile> -> I<../DIRECTORS/director/oldfile> is +supposed to exist. +If I=I, an error will be raised. Otherwise, the following +actions will be performed: + +=over 4 + +=item * The filename in the database will be updated, + +=item * the old target I<../DIRECTORS/director/oldfile> will be renamed to +I<../DIRECTORS/director/newfile>, + +=item * the old symlink will be deleted, and + +=item * a new symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/director/newfile> +will be created. + +=back + + +=item B I<.../DIRECTORS/olddirector/oldfile> I<.../DIRECTOR/newdirector/>[I] + +A symlink I<.../MOVIES/oldfile> -> I<../DIRECTORS/olddirector/oldfile> is +supposed to exist. +If I=I +(or if I=I and I was not given), +an error will be raised. +Otherwise, the following actions will be performed: + +=over 4 + +=item * The filename in the database will be updated if I<>I, + +=item * the old target I<../DIRECTORS/olddirector/oldfile> will be moved to +I<../DIRECTORS/newdirector/newfile>, + +=item * the old symlink will be deleted, and + +=item * a new symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/newdirector/newfile> +will be created. + +=back + + +=item B B<--sort> I [I<.../MOVIES/newfile>] + +Where I is neither of I<.../MOVIES/> nor I<.../DIRECTORS/*/>. +The director will looked for in the database, and and error will be +raised if no entry is found. +Otherwise, the following actions will be performed: + +=over 4 + +=item * The filename in the database will be updated if I<>I, + +=item * the old file will be moved to I<../DIRECTORS/director/newfile> +(or to I<../DIRECTORS/director/oldfile> if the second argument was not +given), + +=item * a symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/director/newfile> +(or I<.../MOVIES/oldfile> -> I<../DIRECTORS/director/oldfile> if the second +argument was not given) will be created. + +=back + +Note that the B<--sort> has to set for this to work; if not, an error +will be raised. + + +=item B I I<.../DIRECTOR/director/>[I] + +Where I is neither of I<.../MOVIES/> nor I<.../DIRECTORS/*/>. +The following actions will be performed: + +=over 4 + +=item * The filename in the database will be updated if I<>I, + +=item * the old file will be moved to I<../DIRECTORS/director/newfile> +(or to I<../DIRECTORS/director/oldfile> if I was not given), + +=item * a symlink I<.../MOVIES/newfile> -> I<../DIRECTORS/director/newfile> +(or I<.../MOVIES/oldfile> -> I<../DIRECTORS/director/oldfile> if the second +argument was not given) will be created. + +=back + +=back + + +=head1 OPTIONS + +=over 8 + +=item B<--sort> + +TODO + +=back + +=head1 EXIT STATUS + +TODO + +=head1 REQUIREMENTS + TODO =head1 AUTHOR @@ -130,9 +303,6 @@ $dbh->disconnect(); ################################################################################ # TODO: find the target from the database instead (option) -# TODO: if the second argument is a directory, don't update database but -# only symlinks (and mv the file in the dir) - sub rename { my ($id, $old_filename, $new_filename) = @_; my $r = 0; @@ -154,7 +324,7 @@ sub rename { chdir $video .'/'. $symlinks or die "Can't cd to `$video/$symlinks': $!"; - # Find the director on the + # Find the previous directory of the file TODO my $old_target = readlink $old_symlink; my $new_target = dirname($old_target) .'/'. $new_filename; @@ -171,6 +341,9 @@ sub rename { } +# TODO: if the second argument is a directory, don't update database but +# only symlinks (and mv the file in the dir) + sub arrange { my ($old_filename, $director) = @_; my $r; -- cgit v1.2.3