Not completely but a bit off topic question: looking for texteditor with macro capabillity

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Not completely but a bit off topic question: looking for texteditor with macro capabillity

Jean-François Rabasse

On Mon, 29 Aug 2011, sleepless wrote:

> Hi,
> One more question. I can imagine that someone got annoyed by this discussion
> in the wrong place, so I decided not to go on with it. But maybe someone has
> a great tip where to discuss bash scripting and maybe after that emacs. After
> all I need to stay productive in Linux and eventually I want to do whatever
> comes in my mind, as I could in good old dos, with just a snap of my fingers
>
> I have been looking around but could not all by myself really find what fits
> my needs. For example: fora where questions have 678 views and zero answers,
> or fora only suited for people who have been digging in to Linux for years.
Hello,

I'm a very new digiKam user, less than two months, but I'm a Unixian
since 1980, over 30 years ! And I'm totaly convinced that scripting,
bash, or Perl, or Python et al., is an (almost) everyday powerful tool
in Unices environments. Whatever application, user oriented with GUI,
you use, you can always open an extra terminal window and do with a few
script lines a lot of stupid and annoying things in a few seconds.
Scripting gives powerful ways to handle files, and gives access to
hundreds of Unix/Linux command line tools.

Wish a fresh example ?
Ten days ago, I came back from holidays with about 400 pictures in my
camera. Too bad but my camera is Nikon and my digiKam version (1.2.0
with exiv2 library 0.19) makes rewriting metadata awfully slow.
(I've timed rewriting data for one image : on my PC, 0.02 sec for
a non Nikon image file, and 6.55 sec for a Nikon image, thus a factor
of 327 !!! Unuseable.)
This topic has been discussed here, and the solution is : upgrade
exiv2 to version 0.20 or 0.21.
If you can. I can't because of the snowball effect, recompile a new
exiv2 library, then recompile digiKam and others things that used the
previous one and don't start any more, and recompile parts of KDE.
Hum, I prefer to be patient and wait for my distribution to be up to
date and consistent.

The quick and temporay solution is bash scripting.
As I don't use the Exif Makernotes every day (far from that), I decided
to remove these notes. Not destroy, remove and save apart.
I wrote a small script, let's call it "removenotes" :

#!/bin/bash
#
for FILE in $*
do
     exiftool -g ${FILE} > ${FILE}.metadata
     exiftool -b -exif:makernotes ${FILE} > ${FILE}.makernotes
     exiftool -q -overwrite_original -exif:makernotes='' ${FILE}
done

That's all. Then, I go into the directory when I moved my SD card
content, about 400 Jpeg files, and just run :
    removenotes *.JPG

In less than 30 sec, I get my images without the Makernotes record
(but all other Exif data) plus a text file with readable Metadata,
just in case, plus a binary dump of the Makernotes record.
(These two extra files total size is less than 20 Kbytes. Compared
to the 8 Mbytes original Jpeg image, disk space isn't an issue.)
And digiKam is happy and very responsive when organising, taging,
etc. Without that dirty trick, I couldn't have done anything.

Just in case I wish, later, to restore full Metainformation in my
files, it's not a problem because of the binary dump kept.
A second script, let's call it "restorenotes"

#!/bin/bash
#
for FILE in $*
do
     exiftool -q -overwrite_original \
        '-exif:makernotes<='${FILE}.makernotes ${FILE}
done

and images files contains Nikon notes again.

My conclusion would be : When you have something stupid to do ten
times, or hundreds or thousands of time, scripting is THE solution.

But that doesn't answer your second question, "Where to discuss
bash scripting ?" Well, I don't think standard forums could be the
solution. Scripting is used in so many contexts that this would
probably require specialised forums covering one application.

And why not a sublist of the digikam-users mailing list ?
Something like digikam-linux-users@..., where people could discuss
topics covering "how can Linux env. and bash scripting help solving
digiKam related problems".
With a separate list, digiKam users that don't feel concerned by the
Linux platform and tools would be protected from that extra lexical
noise :)

All the best,
Jean-François

_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: Not completely but a bit off topic question: looking for texteditor with macro capabillity

Simon Oosthoek-6
In reply to this post by Rinus
On 27/08/11 11:54, sleepless wrote:
> Hi all,
>
> There is so much knowledge around here that I give it a try, i hope
> the moderater will let me.

I don't think there's a moderator on this list ;-)

>
> I have been using for about 25 years PE.exe. This is a programmers
> texteditor from word perfect.
>
> for example you could do in dos ¨dir > dir.lst
>
> open the document pe dir.lst
> it shows for example
>
> a list of
> d:\foto\digikam\photo.jpg
> then very easy make a macro to put in front ¨move ¨ ¨
> then search for ¨\¨ then block and search twice again for ¨\¨
> than copy the ¨\foto\digikam\¨ part
> put at the end of the row ¨¨ O:\and paste
> and add copiedphoto.jpg
> now you have something like
> move ¨d:\foto\digikam\photo.jpg¨ ¨O:\foto\digikam\photo.jpg¨
> and you can apply it to all rows.
>
> make it a batch file and execute.
> wow!
>
> And as you all know by now, I am after saying goodby to windows, this
> is the next problem to tackle.
>
> Yes, it is a horrible example, but how do linux people do things like
> that?
>
>

I used to teach this stuff for a while at AT Computing (Nijmegen)

I saw some very well intended suggestions already, hopefully that has
pointed in the right direction, perhaps I can add a few more...

First of all, the shell (bash probably) is a very complete and powerful
tool, especially in combination with other unix commands. Unfortunately
it is also quite complex to get started and easy to get sent into the
woods and get lost.

a command like:
for f in *; do mv "$f" /someplace/else; done
is already quite an advanced command and easy to get wrong (with
filenames containing spaces and such)

moving lots of files can easily be done using the mv command:
moving all files to an existing directory:
mv * /someplace/else
moving all .jpg files
mv *.jpg /someplace/else

it's important to know that the shell (bash) is modifying the command
before executing it. This makes it possible to move files with spaces in
them, because bash knows that the expanded names with spaces belong
together. (This is due to the order in which the command is interpreted).

All this is contained in the bash manual (man bash), but that is a long
read and you need several iterations of understanding, experimenting and
re-understanding, etc.

the find command can also be useful, but that is at least as complex as
bash to learn how to use correctly...

Cheers

Simon


_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
12