diff options
author | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2011-08-09 15:03:54 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2011-08-09 15:03:54 +0200 |
commit | 6903356ad5c7d966207f41688854288e739aa2e3 (patch) | |
tree | 48159a8ee4cb8a41a82a391febc5fe590277af79 | |
parent | 82806fd253a0bfb3f6c3c84087d94c7ff0e78ecd (diff) |
man
-rwxr-xr-x | videomv.pl | 183 |
1 files changed, 178 insertions, 5 deletions
@@ -41,11 +41,184 @@ videomv.pl - TODO =head1 SYNOPSIS -B<videomv.pl> TODO +B<videomv.pl> [B<--sort>] I<path/to/oldfile> [I<.../>{I<MOVIES>,I<DIRECTORS/director/>}I</>[I<newfile>]] + +video + |- ... + |- DIRECTORS + | |- director1/ + | |- director2/ + | `- ... + `- MOVIES/ =head1 DESCRIPTION +Depending on whether I<path/to/> 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<videomv.pl> [B<--sort>] I<.../MOVIES/oldfile> I<.../MOVIES/newfile> + +I<oldfile> is supposed to be an existing symlink in I<.../MOVIES/>, +which targets to I<../DIRECTORS/director/oldfile>. If +I<oldfile>=I<newfile>, 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<director> will be find on the +database instead of from the old target. + + +=item B<videomv.pl> I<.../MOVIES/oldfile> I<.../DIRECTOR/newdirector/>[I<newfile>] + +I<oldfile> is supposed to be an existing symlink in I<.../MOVIES/>, +which targets to I<../DIRECTORS/olddirector/oldfile>. If +I<olddirector/oldfile>=I<newdirector/newfile> +(or if I<olddirector>=I<newdirector> and I<newfile> 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<oldfile><>I<newfile>, + +=item * the old target will be moved to I<../DIRECTORS/newdirector/newfile>, +(or to I<../DIRECTORS/newdirector/oldfile> if I<newfile> 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<newfile> was not given) +will be created. + +=back + + +=item B<videomv.pl> [B<--sort>] I<.../DIRECTORS/director/oldfile> I<.../MOVIES/newfile> + +A symlink I<.../MOVIES/oldfile> -> I<../DIRECTORS/director/oldfile> is +supposed to exist. +If I<oldfile>=I<newfile>, 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<videomv.pl> I<.../DIRECTORS/olddirector/oldfile> I<.../DIRECTOR/newdirector/>[I<newfile>] + +A symlink I<.../MOVIES/oldfile> -> I<../DIRECTORS/olddirector/oldfile> is +supposed to exist. +If I<olddirector/oldfile>=I<newdirector/newfile> +(or if I<olddirector>=I<newdirector> and I<newfile> 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<oldfile><>I<newfile>, + +=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<videomv.pl> B<--sort> I<path/to/oldfile> [I<.../MOVIES/newfile>] + +Where I<path/to/> 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<oldfile><>I<newfile>, + +=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<videomv.pl> I<path/to/oldfile> I<.../DIRECTOR/director/>[I<newfile>] + +Where I<path/to/> 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<oldfile><>I<newfile>, + +=item * the old file will be moved to I<../DIRECTORS/director/newfile> +(or to I<../DIRECTORS/director/oldfile> if I<newfile> 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; |