diff options
author | Andy Shevchenko <andy@smile.org.ua> | 2006-08-19 06:27:25 +0000 |
---|---|---|
committer | Andy Shevchenko <andy@smile.org.ua> | 2006-08-19 06:27:25 +0000 |
commit | 97daff9a3404219369d46e6fe829db1edb316849 (patch) | |
tree | 949158d1da3f5db462ced47365b04932bab37223 | |
parent | f2a891eb581dab8339867caf7e69770d3594f170 (diff) | |
download | renrot-97daff9a3404219369d46e6fe829db1edb316849.tar.gz renrot-97daff9a3404219369d46e6fe829db1edb316849.tar.bz2 |
Add original file name counter template sequence "%C" and the base part of the original file name to "%O".
%o represents the original filename without modifications.
Tag RenRotFileNameOriginal writing is added.
Fix usage() output formatting and groupping options.
git-svn-id: file:///svnroot/renrot/branches/RENROT_STABLE@244 fe2816f4-e837-0410-b10a-f608c9d244a1
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | etc/renrot.conf | 4 | ||||
-rwxr-xr-x | renrot | 118 |
5 files changed, 104 insertions, 36 deletions
@@ -1,2 +1,8 @@ $Log$ +Revision 1.148.2.1 2006/08/19 06:27:25 andy +Add original file name counter template sequence "%C" and the base part of the original file name to "%O". +%o represents the original filename without modifications. +Tag RenRotFileNameOriginal writing is added. +Fix usage() output formatting and groupping options. + Revision 1.148 2006/07/16 16:59:44 andy @@ -9,3 +15,3 @@ Now skip empty keywords, and remove tail \r if occurs. Add 'no'-prefixed aliases to exist 'no-' options: --norename, --norotate. -New option --no-tags (with alias --notags) switches tags writting. +New option --no-tags (with alias --notags) switches tags writing. @@ -275,3 +281,3 @@ Release as 0.19.1. Revision 1.80 2006/05/17 12:07:14 andy -Unify EXIF writtings to exifWritting(). +Unify EXIF writings to exifWritting(). First attempt to rotation by Orientation tag (new option --only-orientation). @@ -321,3 +327,3 @@ Add no warranty part to README. Correct low case makeup. -Always writting Software tag. +Always writing Software tag. Release as 0.18.3. @@ -5,4 +5,4 @@ EXIF tags. The 'no'-prefixed aliases to the 'no-' options were added: --norename, --norotate, and --notags. The main functionality has been expanded -with keywordizer procedure. See the applied manual to get details of usaging -it. +with the keywordizer procedure. See the applied manual to get details for +using it. @@ -67,2 +67,4 @@ Other +- to implement --include-file option (andy) + - UTF8fy (comments, tags, ...) since it's not implemented in ExifTool yet diff --git a/etc/renrot.conf b/etc/renrot.conf index e24d66a..bf531af 100644 --- a/etc/renrot.conf +++ b/etc/renrot.conf @@ -20,2 +20,3 @@ # %% a literal % +# %C numeric part of the original file name # %c file order number in the processed file set @@ -29,2 +30,5 @@ # %m month (01-12) +# %n previous file name +# %O original file name without extension +# %o original file name # %S second (00-59) @@ -7,2 +7,3 @@ use strict; +use warnings; require 5.006; @@ -30,2 +31,3 @@ if (defined %Image::ExifTool::UserDefined::RenRot) { WRITABLE => 'string', + RenRotFileNameOriginal => { }, RenRotProcessingTimestamp => { }, @@ -93,3 +95,3 @@ my $noRename = 0; # no rename needed, default is to rename to the YYYYmmddHHMMSS my $noRotation = 0; # no rotation needed, default is to rotate -my $noTags = 0; # no tags writting needed +my $noTags = 0; # no tags writing needed my $orientTag = 0; # rotate by changing Orientation tag (no real rotation) @@ -703,3 +705,4 @@ sub renRotProcess { - procmsg ("RENAMING / ROTATING\n===================\n"); + procmsg ("RENAMING / ROTATING\n"); + procmsg ("===================\n"); @@ -796,2 +799,13 @@ sub renameFile { } else { + my $fileNameOriginal = $exifToolObj->GetValue("RenRotFileNameOriginal"); + if (not defined $fileNameOriginal) { + $tags{'RenRotFileNameOriginal'} = {value => $file, group => 'RenRot'}; + $exifTool->SetNewValue("RenRotFileNameOriginal", + $tags{'RenRotFileNameOriginal'}{value}, + Group => $tags{'RenRotFileNameOriginal'}{group}); + dbgmsg (2, "renameFile(): set RenRotFileNameOriginal to $file.\n"); + } else { + dbgmsg (2, "renameFile(): RenRotFileNameOriginal: $fileNameOriginal.\n"); + } + my $ext = ($file =~ m/(\.[^\.]+)$/) ? $1 : ""; @@ -833,3 +847,3 @@ sub getFileData { my @result = getFileDataLines($file); - return join ('', @result) if (scalar(@result) > 0); + return join ("", @result) if (scalar(@result) > 0); return undef; @@ -923,3 +937,4 @@ sub aggregationProcess { - procmsg ("AGGREGATION\n===========\n"); + procmsg ("AGGREGATION\n"); + procmsg ("===========\n"); @@ -1198,3 +1213,3 @@ sub rotateThumbnail { # -# usage() - the instruction how to use the script +# usage() prints the instructions how to use the script # @@ -1209,32 +1224,44 @@ Options: -d, --work-directory <DIR> working directory - --exclude <FILE> ... files to not process. No wildcards. + --exclude <FILE> ... files to not process. No wildcards. -e, --extension <EXTENSION> extension of files to process: JPG, jpeg, ... + +Renaming options: -n, --name-template <TPL> filename template (see manual for details) - --no-rename no rename needed, default is to rename - --counter-fixed-field (*) set fixed field for counter (used in templates) - --counter-start <NUMBER> start to count files to be renamed from - --counter-step <NUMBER> step for files to be renamed counter + --no-rename no rename needed, default is to rename + --counter-fixed-field (*) set fixed field for counter (used in templates) + --counter-start <NUMBER> start to count files to be renamed from + --counter-step <NUMBER> step for files to be renamed counter + +Rotating options: -r, --rotate-angle <ANGLE> angle to rotate file and thumbnail by 90, 180, 270 - --rotate-thumb <ANGLE> rotate only thumbnail by 90, 180, 270 - --only-orientation changing Orientation tag (no real rotation) - --trim (*) pass -trim to jpegtran - --no-rotate no rotation needed, default is to rotate - --mtime (*) set file mtime according to DateTimeOriginal tag - --keywordize (*) set Keywords tag - --keywords-replace (*) replace Keywords tag rather than add value to it - -k, --keywords-file file with keywords - --aggr-mode <MODE> run aggregation (MODE: none, delta, template) - --aggr-delta <INTERVAL> aggregation time delta - --aggr-directory <DIR> aggregation directory name + --rotate-thumb <ANGLE> rotate only thumbnail by 90, 180, 270 + --only-orientation changing Orientation tag (no real rotation) + --no-rotate no rotation needed, default is to rotate + --trim (*) pass -trim to jpegtran + --mtime (*) set file mtime according to DateTimeOriginal tag + +Keywordizing options: + --keywordize (*) set Keywords tag + --keywords-replace (*) replace Keywords tag rather than add value to it + -k, --keywords-file <FILE> file with keywords + +Aggregating options: + --aggr-mode <MODE> run aggregation (MODE: none, delta, template) + --aggr-delta <INTERVAL> aggregation time delta + --aggr-directory <DIR> aggregation directory name -a, --aggr-template <TPL> aggregation template (see manual for details) - --aggr-virtual (*) virtual aggregation (symlinks instead of files) - --aggr-virtual-directory <DIR> root directory for virtual aggregation - --comment-file <FILE> file with text to put into Commentary tag - --user-comment <COMMENTARY> file with text to put into UserComment tag + --aggr-virtual (*) virtual aggregation (symlinks instead of files) + --aggr-virtual-directory <DIR> root directory for virtual aggregation + +Tag writing options: + --comment-file <FILE> file with text to put into Commentary tag + --user-comment <COMMENT> file with text to put into UserComment tag -t, --tag <TAG> ... existent EXIF tag to set in renamed files - --no-tags no tags writting, default is to write tags - --dry-run show what would have been happened - -v [-v -v ...] number of these options defines debug level + --no-tags no tags writing, default is to write tags + +Misc options: + --dry-run show what would have been happened + -v number of these options defines debug level -?, --help display this help and exit - --version output version and exit + --version output version and exit @@ -1246,3 +1273,3 @@ Options: # -# template2name() - file name builder, according the template +# template2name() builds file name according to the template # @@ -1278,2 +1305,5 @@ sub template2name { my $WhiteBalance = ""; + my $fileNameOriginal = ""; + my $fileNameOriginalCounter = ""; # we can't use 0 as default value + my $fileNameOriginalExtensionLess = ""; @@ -1301,2 +1331,13 @@ sub template2name { + if (defined $infoObj->{"RenRotFileNameOriginal"}) { + $fileNameOriginal = $infoObj->{"RenRotFileNameOriginal"}; + # file name starts with letters and ends with digits + if ($fileNameOriginal =~ m/^[[:alpha:]-_]*(\d+)(\.[^\.]+)?$/) { + $fileNameOriginalCounter = $1; + } + if ($fileNameOriginal =~ m/^(.*)\.([^\.]+)$/) { + $fileNameOriginalExtensionLess = $1; + } + } + my @templatearea = split (//, $template); @@ -1305,2 +1346,3 @@ sub template2name { 'a' => $angleSuffix, + 'C' => $fileNameOriginalCounter, 'c' => sprintf($counterSize, $fileNo), @@ -1316,2 +1358,4 @@ sub template2name { 'n' => $base, + 'O' => $fileNameOriginalExtensionLess, + 'o' => $fileNameOriginal, 'S' => $tm[6], @@ -1419,2 +1463,7 @@ B<%%> a literal % +B<%C> the numeric part of the original file name. Implemented for the sake +of the cameras, where no FileNumber EXIF tag is present (currently all except +Canon). Filename would started by letters and ended by digits. No other +symbols are not allowed, except C<->, C<.> and C<_>. + B<%c> file order number in the processed file set (also see @@ -1441,3 +1490,10 @@ B<%m> month (01-12) -B<%n> old filename +B<%n> previous filename (the one before the current processing with renrot) + +B<%O> base part of the original filename (see B<%o>). In other words the +first part from the begin to the last dot symbol. + +B<%o> the name, file had before first processing with renrot. If the file +was processed with renrot if only once, the tag RenRotFileNameOriginal written +with the file name. |