Bug 132982 - Batch rename limited, should allow renaming by patterns
Summary: Batch rename limited, should allow renaming by patterns
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: AdvancedRename-file (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-25 18:42 UTC by Gregor Hoffleit
Modified: 2022-01-31 21:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.5.0


Attachments
Patch for extra renaming options (for version 0.1.4) (8.21 KB, patch)
2007-10-20 01:56 UTC, Piotr Tarnowski
Details
Screenshot of patched rename plugin (27.66 KB, image/jpeg)
2007-10-20 01:59 UTC, Piotr Tarnowski
Details
Update patch for extra renaming options (8.66 KB, patch)
2007-10-22 08:53 UTC, Piotr Tarnowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Hoffleit 2006-08-25 18:42:54 UTC
Version:            (using KDE KDE 3.5.4)
Installed from:    Debian testing/unstable Packages0

Batch rename currently supports only a very limited set of renaming schemes.

Just one example, it does not support the naming scheme proposed by exiflow (http://exiflow.sourceforge.net/), where the number is extracted from the original file name and prefixed by a date format and some other information pieces:

    dsc_1234.nef -> 20050412-n001234-ur000.nef

I'd suggest to remove the currently hardcoded and limited rename options from renameimageswidget in favor of a more general solution. One might just adopt the code from krename, where the following pattern would to the job:

    [creationdate;yyyyMMdd]-n00[%5-8]-ur000[%9-]

The patterns used in krename are flexible enough to replace all options that are currently available in batch rename (the only option missing is extraction of the EXIF image date). If necessary, one could even reimplement the current options on top of this patterns.
Comment 1 Piotr Tarnowski 2007-10-20 01:56:46 UTC
Created attachment 21869 [details]
Patch for extra renaming options (for version 0.1.4)

I've made this patch to extend limited rename capabilities of this plugin.
When extra check box is checked follwing happens:
* neither extension nor number is added by default
* one can use following extra symbols in Date format:
[e] - extension as is
[e-] - extension lower case
[e+] extension upper case
[i] - sequence number - no leading zeros
[i:4] - sequence number in 4 digit with leading zeros format 
[n] - original file name
[n+] - original file name upper case
[n-] - original file name lower case
[n:5..-2] - substring of original filename from char 5 to second from the end
(either 5 or -2 can be empty which means from beginning or to the end, both
star and stop numbers can be positive (from begining) or negative (from end)
also + or - can be used after n)
Also polish translation of new check label is provided.

This patch does not bring the power of krename to kipi but is powerful enough
form most cases. There is screen shot provided in next attachment.
Comment 2 Piotr Tarnowski 2007-10-20 01:59:33 UTC
Created attachment 21870 [details]
Screenshot of patched rename plugin

Just a sample of renaming options - part of original name used, arbitrary
formated counter and lowercase extension mixed with date formating.

Piotr
Comment 3 Piotr Tarnowski 2007-10-22 08:53:54 UTC
Created attachment 21893 [details]
Update patch for extra renaming options

I didn't realize that there is "complete" extension and "complete" baseName.
So now I allow all of these in extra tags, which additionally all have the same
syntax which match following examples: 
[a] - album name
[p+] - absolute path (uppercase)
[e] - extension (small one - after last '.')
[B:4..-2] - base name (big one - all before last ',', from 4-th to one before
last characters)
[n+:..5] - whole name (base + extension, characters from 1 to 5)
[b-:-3..] - base name (small one - all before first '.', last 3 characters)
Comment 4 tomas 2007-10-22 14:14:34 UTC
well, I like it and would suggest something like this for us with a bad memory:

--- renameimageswidget.cpp.old  2007-10-22 14:04:35.000000000 +0200
+++ renameimageswidget.cpp      2007-10-22 14:08:28.000000000 +0200
@@ -41,6 +41,7 @@
 #include <qpopupmenu.h>
 #include <qregexp.h>
 #include <qdir.h>
+#include <qtooltip.h>

 #include <libkipi/interface.h>
 #include <libkipi/imageinfo.h>
@@ -94,6 +95,21 @@
             SLOT(slotOptionsChanged()));
     connect(m_addFileNameCheck, SIGNAL(toggled(bool)),
             SLOT(slotOptionsChanged()));
+       QToolTip::add(m_useExtraSymbolsCheck,
+                       "[e] - extension (small one - after last '.')\n"
+                       "[e-] - extension lower case\n"
+                       "[e+] extension upper case\n"
+                       "[i] - sequence number - no leading zeros\n"
+                       "[i:4] - sequence number in 4 digit with leading zeros format\n"
+                       "[n] - original file name\n"
+                       "[n+] - original file name upper case\n"
+                       "[n-] - original file name lower case\n"
+                       "[n:5..-2] - substring of original filename from char 5 to second from the end\n"
+                       "[n+:..5] - whole name (base + extension, characters from 1 to 5)\n"
+                       "[a] - album name\n"
+                       "[p+] - absolute path (uppercase)\n"
+                       "[B:4..-2] - base name (big one - all before last ',', from 4-th to one before last characters)\n"
+                       "[b-:-3..] - base name (small one - all before first '.', last 3 characters)");
     connect(m_useExtraSymbolsCheck, SIGNAL(toggled(bool)),
             SLOT(slotOptionsChanged()));
     connect(m_addFileDateCheck, SIGNAL(toggled(bool)),
Comment 5 caulier.gilles 2008-12-08 09:32:46 UTC
There is a patch to test here...

Somebody can check it ?

Gilles Caulier

Comment 6 Aurelien Gateau 2008-12-10 23:30:04 UTC
SVN commit 895529 by gateau:

Applied patches from Piotr Tarnowski and tomas to provide more formating
options to the batch renamer.
BUG:132982


 M  +9 -1      renameimagesbase.ui  
 M  +109 -15   renameimageswidget.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=895529