diff options
author | Zeus Panchenko <zeus@camb.us> | 2006-05-03 21:59:52 +0000 |
---|---|---|
committer | Zeus Panchenko <zeus@camb.us> | 2006-05-03 21:59:52 +0000 |
commit | 2dbb147f602abaa3eabb5ccb003a84acfc9c0b95 (patch) | |
tree | 56ad554c7202e456636c05e0d5d62367cd5aa876 | |
parent | 29f01cde1ce5f31ca93429f329c99e9c5d09b2d6 (diff) | |
download | renrot-2dbb147f602abaa3eabb5ccb003a84acfc9c0b95.tar.gz renrot-2dbb147f602abaa3eabb5ccb003a84acfc9c0b95.tar.bz2 |
file aggregation via option --aggr-template has been implemented.
control code for file name originality has been moved from template2name() to main().
README edited
git-svn-id: file:///svnroot/renrot/trunk@88 fe2816f4-e837-0410-b10a-f608c9d244a1
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | README | 9 | ||||
-rwxr-xr-x | renrot | 75 |
3 files changed, 77 insertions, 14 deletions
@@ -1,7 +1,12 @@ | |||
1 | $Log$ | 1 | $Log$ |
2 | Revision 1.57 2006/05/03 21:59:52 zeus | ||
3 | file aggregation via option --aggr-template has been implemented. | ||
4 | control code for file name originality has been moved from template2name() to main(). | ||
5 | README edited | ||
6 | |||
2 | Revision 1.56 2006/05/02 19:08:59 zeus | 7 | Revision 1.56 2006/05/02 19:08:59 zeus |
3 | item about aggregation is added to TODO. | 8 | item about aggregation is added to TODO. |
4 | minor language ixes in README | 9 | minor language ixes in README. |
5 | 10 | ||
6 | Revision 1.55 2006/05/02 09:07:02 andy | 11 | Revision 1.55 2006/05/02 09:07:02 andy |
7 | Wrote RESTRICTIONS section in README. | 12 | Wrote RESTRICTIONS section in README. |
@@ -8,7 +8,7 @@ of project is short form of 'REName and ROTate' and no other interpretation | |||
8 | will be used. | 8 | will be used. |
9 | 9 | ||
10 | Renrot is intended to work only in current directory with all files of the | 10 | Renrot is intended to work only in current directory with all files of the |
11 | extension, specified after --ext. You can change the behaviour by specify | 11 | extension, specified after --ext. You can change the behaviour by specifying |
12 | --work-directory option. | 12 | --work-directory option. |
13 | 13 | ||
14 | New template ideology was implemented. It includes flexibility in file name | 14 | New template ideology was implemented. It includes flexibility in file name |
@@ -28,6 +28,8 @@ Furthermore, the script can put a comment to: | |||
28 | 28 | ||
29 | Personal data could be specified via XMP tags defined in configuration file. | 29 | Personal data could be specified via XMP tags defined in configuration file. |
30 | 30 | ||
31 | In addition renrot can aggregate all files in directories according the given | ||
32 | date/time pattern template, set with --aggr-template. | ||
31 | 33 | ||
32 | WHY RenRot? | 34 | WHY RenRot? |
33 | 35 | ||
@@ -41,6 +43,7 @@ namely RenRot? Because: | |||
41 | libjpeg6 (the best open tool to operate JPEG format files, to correctly | 43 | libjpeg6 (the best open tool to operate JPEG format files, to correctly |
42 | rotate both, the very file and the thumbnail inside it); | 44 | rotate both, the very file and the thumbnail inside it); |
43 | - it has very much flex file naming template engine; | 45 | - it has very much flex file naming template engine; |
46 | - it has very much flex file aggregation template engine; | ||
44 | - it works in batch mode. | 47 | - it works in batch mode. |
45 | 48 | ||
46 | 49 | ||
@@ -61,6 +64,10 @@ applications of the script: | |||
61 | rename each file according to the given template | 64 | rename each file according to the given template |
62 | renrot --name-template="01.%c.%Y%m%d%H%M%S.%i.%E%F%W%I" --ext JPG | 65 | renrot --name-template="01.%c.%Y%m%d%H%M%S.%i.%E%F%W%I" --ext JPG |
63 | 66 | ||
67 | rename each file according to the given template and files aggregation | ||
68 | according the date | ||
69 | renrot --name-template="%y%m%d%H%M%S.%i" --aggr-template "%Y%m%d" --ext JPG | ||
70 | |||
64 | rotate each file and their thumbnail by 90CW in specified directory | 71 | rotate each file and their thumbnail by 90CW in specified directory |
65 | renrot --rotate 90 --ext '*.jpg' --work-directory="/tmp/images" | 72 | renrot --rotate 90 --ext '*.jpg' --work-directory="/tmp/images" |
66 | 73 | ||
@@ -19,6 +19,7 @@ my $rotateThumbnail; # define the angle, to rotate on, 90 or 270 | |||
19 | my $noRename; # no rename needed, default is to rename to the YYYYmmddHHMMSS.jpg | 19 | my $noRename; # no rename needed, default is to rename to the YYYYmmddHHMMSS.jpg |
20 | my $noComment; # no comment needed | 20 | my $noComment; # no comment needed |
21 | my $nameTemplate; # template for the filename taken from CLI | 21 | my $nameTemplate; # template for the filename taken from CLI |
22 | my $aggrTemplate; # template for the files aggregation taken from CLI | ||
22 | my $extentionToProcess; # the extention of files to work with | 23 | my $extentionToProcess; # the extention of files to work with |
23 | my $extentionToProcessLowCase; # lowercased extention of files to work with | 24 | my $extentionToProcessLowCase; # lowercased extention of files to work with |
24 | my $usageOutput = 0; # flag to show the usage | 25 | my $usageOutput = 0; # flag to show the usage |
@@ -71,6 +72,7 @@ sub getopt { | |||
71 | "no-rename" => \$noRename, | 72 | "no-rename" => \$noRename, |
72 | "comment-file=s" => \$comfile, | 73 | "comment-file=s" => \$comfile, |
73 | "name-template=s" => \$nameTemplate, | 74 | "name-template=s" => \$nameTemplate, |
75 | "aggr-template=s" => \$aggrTemplate, | ||
74 | "mtime" => \$mtime, | 76 | "mtime" => \$mtime, |
75 | "config-file|c=s" => \$configFile, | 77 | "config-file|c=s" => \$configFile, |
76 | "v+" => \$verbose, | 78 | "v+" => \$verbose, |
@@ -247,15 +249,23 @@ foreach $file ( @files ) { | |||
247 | # | 249 | # |
248 | if ( defined $noRename ) { | 250 | if ( defined $noRename ) { |
249 | infomsg ("No renaming asked, filename is left untouched.\n"); | 251 | infomsg ("No renaming asked, filename is left untouched.\n"); |
250 | $newfilename = $file; | 252 | if ( ($newfilename) = ( $file =~ /^(.*)\.jpg/ ) ) { |
253 | $filenameshash{$newfilename} = 1; | ||
254 | } | ||
251 | } | 255 | } |
252 | else { | 256 | else { |
253 | $newfilename = sprintf("%s.%s", template2name($NameTemplate), $extentionToProcessLowCase); | 257 | $newfilename = template2name($NameTemplate); |
258 | if ( $filenameshash{$newfilename} ) { | ||
259 | $newfilename = sprintf("%s.%.4d",$newfilename,$filecounter); | ||
260 | } | ||
261 | $filenameshash{$newfilename} = 1; | ||
262 | |||
263 | $newfilename = sprintf("%s.%s", $newfilename, $extentionToProcessLowCase); | ||
254 | 264 | ||
255 | if ( $file ne $newfilename ) { | 265 | if ( $file ne $newfilename ) { |
256 | if ( -f $newfilename ) { | 266 | if ( -f $newfilename ) { |
257 | fatalmsg ("File $newfilename already exists!\n"), die | 267 | fatalmsg ("File $newfilename already exists!\n"), die; |
258 | }; | 268 | } |
259 | rename ( $file, $newfilename ) | 269 | rename ( $file, $newfilename ) |
260 | || ( fatalmsg ("Unable to rename $file -> $newfilename.\n"), die ); | 270 | || ( fatalmsg ("Unable to rename $file -> $newfilename.\n"), die ); |
261 | print "Renamed: $file -> $newfilename\n"; | 271 | print "Renamed: $file -> $newfilename\n"; |
@@ -342,6 +352,27 @@ foreach $file ( @files ) { | |||
342 | 352 | ||
343 | closedir(DIR); | 353 | closedir(DIR); |
344 | 354 | ||
355 | ######################################################################################## | ||
356 | # | ||
357 | # file aggregation if requested | ||
358 | # | ||
359 | if ( defined $aggrTemplate ) { | ||
360 | infomsg ("NOW IS FILE AGGREGATION\n=======================\n\n"); | ||
361 | $filecounter=1; | ||
362 | foreach $file ( sort ( keys %filenameshash ) ) { | ||
363 | $file .= ".jpg"; | ||
364 | $info = $exifTool->ImageInfo($file); | ||
365 | $newfilename = template2name($aggrTemplate); | ||
366 | if ( not -d $newfilename ) { | ||
367 | unless ( mkdir $newfilename ) { errmsg ("$newfilename wasn't created!\n"); } | ||
368 | } | ||
369 | infomsg ( "$file has been aggregated to the directory $newfilename\n" ); | ||
370 | $newfilename .= "/" . $file; | ||
371 | rename ( $file, $newfilename ) || ( fatalmsg ("$file -> $newfilename\n"), die ); | ||
372 | $filecounter++; | ||
373 | } | ||
374 | } | ||
375 | |||
345 | exit 0; | 376 | exit 0; |
346 | 377 | ||
347 | ######################################################################################## | 378 | ######################################################################################## |
@@ -404,7 +435,7 @@ sub getTimestamp { | |||
404 | $timestamp = timeNow(); | 435 | $timestamp = timeNow(); |
405 | warnmsg ("EXIF timestamp isn't correct, using timeNow()!\n"); | 436 | warnmsg ("EXIF timestamp isn't correct, using timeNow()!\n"); |
406 | } | 437 | } |
407 | 438 | ||
408 | return $timestamp; | 439 | return $timestamp; |
409 | } | 440 | } |
410 | 441 | ||
@@ -553,6 +584,7 @@ infomsg ( | |||
553 | it's for the files which were rotated, but thumbnail wasn't | 584 | it's for the files which were rotated, but thumbnail wasn't |
554 | --no-rename no rename needed, default is to rename to the YYYYmmddHHMMSS.jpg | 585 | --no-rename no rename needed, default is to rename to the YYYYmmddHHMMSS.jpg |
555 | --name-template <TPL> filename template (see manual for details) | 586 | --name-template <TPL> filename template (see manual for details) |
587 | --aggr-template <TPL> aggregation template (see manual for details) | ||
556 | --mtime to set file mtime according DateTimeOriginal tag value | 588 | --mtime to set file mtime according DateTimeOriginal tag value |
557 | --comment-file <FILE> file with commentary | 589 | --comment-file <FILE> file with commentary |
558 | --version the version of this script | 590 | --version the version of this script |
@@ -637,12 +669,6 @@ sub template2name { | |||
637 | else { $thename .= $substrchar; } | 669 | else { $thename .= $substrchar; } |
638 | } | 670 | } |
639 | 671 | ||
640 | if ( $filenameshash{$thename} ) { | ||
641 | $thename = sprintf("%s.%s",$thename,$templatehash{"c"}); | ||
642 | } | ||
643 | |||
644 | $filenameshash{$thename} = 1; | ||
645 | |||
646 | return $thename; | 672 | return $thename; |
647 | } | 673 | } |
648 | 674 | ||
@@ -659,7 +685,7 @@ renrot [OPTIONS] | |||
659 | =head1 DESCRIPTION | 685 | =head1 DESCRIPTION |
660 | 686 | ||
661 | B<RenRot> is intended to work ONLY in current directory. You can change the | 687 | B<RenRot> is intended to work ONLY in current directory. You can change the |
662 | behaviour by specify B<--work-directory> option. | 688 | behaviour by specifying B<--work-directory> option. |
663 | 689 | ||
664 | Renrot renames files according the DateTimeOriginal and FileModifyDate EXIF | 690 | Renrot renames files according the DateTimeOriginal and FileModifyDate EXIF |
665 | tags, if they exist. Otherwise, the name will be set according to the current | 691 | tags, if they exist. Otherwise, the name will be set according to the current |
@@ -684,6 +710,9 @@ The script can also put commentary into: | |||
684 | Personal details can be specified via XMP tags defined in a configuration | 710 | Personal details can be specified via XMP tags defined in a configuration |
685 | file, look L<CONFIG> section. | 711 | file, look L<CONFIG> section. |
686 | 712 | ||
713 | In addition renrot can aggregate all files in directories according the given | ||
714 | date/time pattern template, set with B<--aggr-template>. | ||
715 | |||
687 | =head1 OPTIONS | 716 | =head1 OPTIONS |
688 | 717 | ||
689 | =over | 718 | =over |
@@ -780,6 +809,28 @@ B<%y> last two digits of year (00..99) | |||
780 | 809 | ||
781 | =back | 810 | =back |
782 | 811 | ||
812 | =item B<--aggr-template> I<Aggregation TEMPLATE> | ||
813 | |||
814 | template, which is used for file aggregation. Aggragation fulfils according date/time patterns. | ||
815 | |||
816 | =over | ||
817 | |||
818 | B<%d> day of the month (01-31) | ||
819 | |||
820 | B<%H> hour (00-23) | ||
821 | |||
822 | B<%M> minute (00-59) | ||
823 | |||
824 | B<%m> month (01-12) | ||
825 | |||
826 | B<%S> second (00-59) | ||
827 | |||
828 | B<%Y> year (1900, 1901, and so on) | ||
829 | |||
830 | B<%y> last two digits of year (00..99) | ||
831 | |||
832 | =back | ||
833 | |||