Writing Userdefined Tag with filename

Started by ezeeckiel, April 15, 2013, 06:05:06 AM

Previous topic - Next topic

ezeeckiel

Dear Phil,

Thanks a lot for this amazing tool i'm discovering. It seems perfect to handle the files I have. My goal is to add userdefined tags to my files so later on I could seek through them with queries like: give me the jpg files where userdefined1=value, etc...

Now I'm struggling with the command line
All files in directory are written so :
name1_01.jpg
name1_02.jpg
name2_01.jpg
name3_01.jpg
...


What I would like to do is :
for all files in a directory
add newEXIFTag
and fill it with nameX

I can't figure how to write the -NewEXIFTag=%f??

Also, I'm a bit confused about how to use the batch mode. It seems for me that some operation needs a .bat file written as so :
#!/bin/bash
exiftool command line

and some others don't. If you could clarify this point, i should be able to understand better (if needed)
cheers
Olivier

Phil Harvey

Hi Olivier,

The command is:

exiftool "-userdefined1<basename" "-userdefined2<basename" DIR

where DIR is the directory name.  For this command to work, the "userdefined" and "basename" must be defined.  The sample config file defines the BaseName Composite tag, and shows you how to define your own user-defined EXIF tags.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ezeeckiel

Dear Phil,
Thanks for the quick answer,
Now I have some clues where to begin !
I'll let you know how things go
Olivier

ezeeckiel

Dear Philip,

I've tried to figure out how to use substr but I'm stuck

here is the config file. I got the idea from an other post :
  BaseName => {
            Require => {
                0 => 'FileName',
            },
            # remove the extension from FileName
            ValueConv => 'my $name=$val[0]; $name=~s/\..*?$//; $name',
        },
BaseNameLast => {
Require => {
0 => 'BaseName',
      },
ValueConv => 'my $name=$val[0]; my $pos=index($name, "_")+1; $name=substr($name, $pos - $name)',
    },


My files are
aaaaa_xx.jpg
bbbbb_xx.jpg
cccccc_xxx.jpg   (sometimes more than 100 have the same name)

I would like to get the file name whitout the _xx or _xxx
does rsubstr work with exiftool ? I can't make it work either

cheer
sOli

Phil Harvey

Try this:

ValueConv => 'my $name=$val[0]; $name=~s/_.*?$//; $name',

this removes everything from the first underline onwards.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ezeeckiel


Phil Harvey

Glad that worked.  I'm just posting back to note that I misspoke.  That expression will remove everything from the last underline onwards, not the first.  (In case there are more than one underlines.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).