Main Menu

Create Custom Tag

Started by Retired, April 21, 2013, 08:05:17 AM

Previous topic - Next topic

Retired

I am a pensioner and I am doing this here just for fun.
I am an absolute beginner.

I can't figure out how to create a customized tag.
I am using VBA (Access) calling the exiftool.exe

The tag should be a string named "GoogleShortpath"

Reading the FAQ, I at first have created an .exifTool.config like this:

'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },

In VBA I now tried this:
Public Function CreateTag_Userdefined(ByVal exiftag As String, ByVal Newvalue As String, Picname As String) As Boolean
lngHandle = Shell(CurrentProject.Path & "\exifTool.exe -k " & " -" & exiftag & "=" & Chr(34) & Newvalue & Chr(34) & " " & Chr(34) & Picname & Chr(34))

But this doesn't work.
I only get a message that the tag doesn't exist.
So, how to do it?
Any suggestions?
Pls. explain in plain words.

Regards
Juergen

Phil Harvey

Hi Juergen,

I always recommend trying the exiftool from the command line first because you miss useful error messages if you run from within another application (unless you capture and display the stderr output).

If you do this, you will see a syntax error from your config file.  (Assuming that ExifTool finds the config file that is.)

Try this config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end


Also, be sure the config file name is ".ExifTool_config", and that it is in your home directory or the directory of the exiftool program.

- 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 ($).

Retired

Hi, Phil,
thanks for the quick answer.
At first I have renamed the config-file.
Had been my mistake.

Then I copied your code into the file.

[Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end

There is nothing more in that file.

Trying to execute with "Shell...", I get the following errors:
Operator or semicolon missing before %Image::ExifTool::UserDefined at E:\TestExi
fPics\Memories_DB\.ExifTool_config line 2.
Ambiguous use of % resolved as operator % at E:\TestExifPics\Memories_DB\.ExifTo
ol_config line 2.
Can't modify modulus (%) in scalar assignment at E:\TestExifPics\Memories_DB\.Ex
ifTool_config line 9, near ");"
Warning: Tag 'GoogleShortcut' does not exist
Nothing to do.
-- press any key –

Quite sure, that my command line is wrong.
How should it look like?

Juergen

StarGeek

[Select] should not be part of the config file.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Retired

Tnx, I now have deleted "[Select]" in the config file

The command line now looks like that:
E:\>exiftool -k -GoogleShotcut="xyz" E:\Test.jpg"

The message I get:
Can't modify constant item in scalar assignment at E:\.ExifTool_config line 8, near ");"
Warning: Tag 'GoogleShotcut' does not exist
Nothing to do.
-- press any key --

Juergen

Retired

O sorry,
The command line had been like this:
E:\exiftool -k -GoogleShotcut="xyz" "E:\Test.jpg"

Phil Harvey

The warning makes it sound like one of the "=>" in the file is a "=" by mistake.

Can you attach your config file here so I can take a look?

- 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 ($).

StarGeek

Quote from: Retired on April 22, 2013, 01:11:03 PM
O sorry,
The command line had been like this:
E:\exiftool -k -GoogleShotcut="xyz" "E:\Test.jpg"

While I don't think it's what's causing your problem in this case, make sure that you use regular quotes, not fancy quotes as you did to the left of the E here. 

Fancy " " vs regular " "
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Retired

At first thanks for your patience with me.

I have corrected the config file and now it looks like this:

%Image::ExifTool::UserDefined => (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end

But trying to write a value I still get the message
Tag 'GoogleShortpath' does not exist.
Command:
(Exiftool –k –GoogleShortpath=xyz test.jpg)

So do I need to run a command beforehand to create the tag?

Phil Harvey

We're cycling around here. The error you got indicates that the config file was not loaded properly.  Try loading it via the command line option to see if this works:

exiftool -config your_config_file_name.cfg -k -googleshortpath=xxx test.jpg

(note that the -config option must come first on the command line)

- 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 ($).

Retired

Hi Phil,

Tnx for the command line.
But it's still the same.

E:\>exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
Warning: Tag 'Googleshortpath' does not exist

As you can see, there are no other warnings or error messages.

Phil Harvey

Try attaching the config file you are using and I'll see if I can duplicate the problem.

- 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 ($).

Retired

Tnx Phil,
attached you will find the config file

Phil Harvey

OK.  With the config file you posted, I got this:

> exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
Useless use of a variable in void context at test.cfg line 1.
Useless use of a constant (Image::ExifTool::IPTC::ApplicationRecord) in void context at test.cfg line 1.
Useless use of anonymous hash ({}) in void context at test.cfg line 1.
Warning: Tag 'Googleshortpath' does not exist
Nothing to do.


When I fixed the config file (changed the first "=>" back to "="), it works:

> exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
    1 image files updated
> exiftool -config test.cfg -k -Googleshortpath Test.jpg
Googleshortpath                 : xxx


Attached is the fixed config file.

(btw, the -k is not necessary when running from the command line.)

- 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 ($).

Retired

Hallo Phil,
I wasn't online for some days.
Now I saw your new config file.
With that file it all works like a charm.

Let me say "THANKS" again.
I never have seen a better support, especially if one takes in his mind that you are doing this in your leisure time.