summaryrefslogtreecommitdiffabout
authorAndy Shevchenko <andy@smile.org.ua>2006-08-19 06:27:25 (GMT)
committer Andy Shevchenko <andy@smile.org.ua>2006-08-19 06:27:25 (GMT)
commit97daff9a3404219369d46e6fe829db1edb316849 (patch) (side-by-side diff)
tree949158d1da3f5db462ced47365b04932bab37223
parentf2a891eb581dab8339867caf7e69770d3594f170 (diff)
downloadrenrot-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog12
-rw-r--r--NEWS4
-rw-r--r--TODO2
-rw-r--r--etc/renrot.conf4
-rwxr-xr-xrenrot118
5 files changed, 104 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index b7d75b6..00197ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
$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
Release as 0.22.
@@ -7,7 +13,7 @@ Remove fatal case when keywords file isn't exist.
Fix return value in the getFileDataLines() and keywordizer().
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.
Revision 1.146 2006/07/13 13:07:39 zeus
Tags initialization moved from tagWriter() to the renRotProcess().
@@ -273,7 +279,7 @@ Implement exclude list (option --exclude <FILE>).
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).
Remove unused variables.
@@ -319,7 +325,7 @@ Revert back --no-rotate and --no-rename.
Exclude single quotas from README examples part due to undesired interpretation in cmd.exe. Also, put note to README.Windows.
Add no warranty part to README.
Correct low case makeup.
-Always writting Software tag.
+Always writing Software tag.
Release as 0.18.3.
Revision 1.70 2006/05/11 10:11:47 zeus
diff --git a/NEWS b/NEWS
index fa16ff5..20abdd7 100644
--- a/NEWS
+++ b/NEWS
@@ -3,8 +3,8 @@
A new option --no-tags has been added. Use it when you don't want to write
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.
* 0.21.1 *
diff --git a/TODO b/TODO
index 78f7ebf..29b68b0 100644
--- a/TODO
+++ b/TODO
@@ -65,5 +65,7 @@ Code
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
@@ -18,6 +18,7 @@
# Template is used for file name building while renaming. Interpreted
# sequences are:
# %% a literal %
+# %C numeric part of the original file name
# %c file order number in the processed file set
# %d day of the month (01-31)
# %E ExposureTime tag value if defined
@@ -27,6 +28,9 @@
# %i FileNumber tag if exists (otherwise, it'll be replaced by string "NA")
# %M minute (00-59)
# %m month (01-12)
+# %n previous file name
+# %O original file name without extension
+# %o original file name
# %S second (00-59)
# %W WhiteBalance tag value if defined
# %Y year (1900, 1901, and so on)
diff --git a/renrot b/renrot
index 0a2c428..ece96e6 100755
--- a/renrot
+++ b/renrot
@@ -5,6 +5,7 @@
#
use strict;
+use warnings;
require 5.006;
use Time::localtime;
use Time::Local;
@@ -28,6 +29,7 @@ if (defined %Image::ExifTool::UserDefined::RenRot) {
GROUPS => { 0 => 'XMP', 1 => 'RenRot', 2 => 'Image' },
NAMESPACE => [ 'RenRot' => 'http://freshmeat.net/projects/renrot/' ],
WRITABLE => 'string',
+ RenRotFileNameOriginal => { },
RenRotProcessingTimestamp => { },
RenRotVersion => { },
RenRotURL => { },
@@ -91,7 +93,7 @@ my $mtime; # mtime taken from CLI
my $nameTemplate; # template for the filename taken from CLI
my $noRename = 0; # no rename needed, default is to rename to the YYYYmmddHHMMSS.ext
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)
my $quiet = 0; # suppressing messages
my $rotateAngle; # define the angle to rotate on 90, 180 or 270
@@ -701,7 +703,8 @@ sub renRotProcess {
$exifTool->SetNewValue($key, $tags{$key}{value}, Group => $tags{$key}{group});
}
- procmsg ("RENAMING / ROTATING\n===================\n");
+ procmsg ("RENAMING / ROTATING\n");
+ procmsg ("===================\n");
foreach my $file (@files) {
procmsg ("Processing file: $file ...\n");
@@ -794,6 +797,17 @@ sub renameFile {
$newFileName = $file;
$filenameshash{$newFileName} = $unixTime;
} 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 : "";
my $extLen = length($ext);
@@ -831,7 +845,7 @@ sub renameFile {
sub getFileData {
my $file = shift;
my @result = getFileDataLines($file);
- return join ('', @result) if (scalar(@result) > 0);
+ return join ("", @result) if (scalar(@result) > 0);
return undef;
}
@@ -921,7 +935,8 @@ sub aggregationProcess {
my $info;
my $NewDir;
- procmsg ("AGGREGATION\n===========\n");
+ procmsg ("AGGREGATION\n");
+ procmsg ("===========\n");
if ($configOptions{'aggregation mode'} eq "template") {
dbgmsg (1, "aggregationProcess(): Template: $configOptions{'aggregation template'}\n");
@@ -1196,7 +1211,7 @@ sub rotateThumbnail {
########################################################################################
#
-# usage() - the instruction how to use the script
+# usage() prints the instructions how to use the script
#
sub usage {
infomsg (
@@ -1207,36 +1222,48 @@ infomsg (
Options:
-c, --config-file <FILE> configuration file to use
-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
(*) The option does not take an argument and may be negated, i.e. prefixed by 'no'. E.g. 'mtime' will allow '--mtime' (positive value will be assigned) and '--nomtime' or '--no-mtime' (negative value will be assigned).
");
@@ -1244,7 +1271,7 @@ Options:
########################################################################################
#
-# template2name() - file name builder, according the template
+# template2name() builds file name according to the template
#
sub template2name {
my $exifToolObj = shift;
@@ -1276,6 +1303,9 @@ sub template2name {
my $FNumber = "";
my $ISO = "";
my $WhiteBalance = "";
+ my $fileNameOriginal = "";
+ my $fileNameOriginalCounter = ""; # we can't use 0 as default value
+ my $fileNameOriginalExtensionLess = "";
if (defined $infoObj->{"FileNumber"}) {
$FileNumber = $infoObj->{"FileNumber"};
@@ -1299,10 +1329,22 @@ sub template2name {
$WhiteBalance =~ s/[\s()]//g;
}
+ 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);
my %templatehash = (
'%' => "%",
'a' => $angleSuffix,
+ 'C' => $fileNameOriginalCounter,
'c' => sprintf($counterSize, $fileNo),
'd' => $tm[3],
'E' => $ExposureTime,
@@ -1314,6 +1356,8 @@ sub template2name {
'M' => $tm[5],
'm' => $tm[2],
'n' => $base,
+ 'O' => $fileNameOriginalExtensionLess,
+ 'o' => $fileNameOriginal,
'S' => $tm[6],
'W' => $WhiteBalance,
'Y' => $tm[0],
@@ -1417,6 +1461,11 @@ Interpreted sequences are:
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
B<--counter-fixed-field> option)
@@ -1439,7 +1488,14 @@ B<%M> minute (00-59)
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.
B<%S> second (00-59)

Return to:

Send suggestions and report system problems to the System administrator.