Create keyword from the file name, all name till first underscore

Started by seraosr, November 22, 2012, 01:27:27 PM

Previous topic - Next topic

seraosr

Hi Phil, thanks again for your kindly help.

Did the test with the code and command you send and no result.

Think that, the field "XMP: Subject" is the same that field "Keywords" on a PDF file.

On PDF file Keywords are duplicated, even wit "<" signal. I think that with code you sent, exif is writing on a XMP Subject.

Attached the Export Metadata from and the PDF file, before and after execute command you sent exiftool "-keywords<keywords" FILE.

Thank you
Regards

Phil Harvey

Oops.  I made a mistake.  The command should have been:

exiftool "-keywords<myname2" FILE

Also, what I was trying to do wouldn't work because the file name is the 3rd keyword.

It helps a lot that you have included the original PDF.  The original PDF:Keywords are:

1) "Porto"
2) "Editora:"
3) "CESPI-REC_20000000_TXT.pdf"

If you want them changed to:

1) "Porto"
2) "Editora:"
3) "CESPI-REC"

then use this config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        Myname2 => {
               Require => 'Keywords',
               ValueConv => q{
                   my @list = ref $val eq 'ARRAY' ? @$val : ($val);
                   s/_\w+\.pdf//i foreach @list;
                   return \@list;
               },
        },
    },
);


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

seraosr

No mistakes Phil. Your help is priceless.

I have this message, and PDF isn't processed.

C:\EXIF>exiftool "-keywords+<Myname2" C:\EXIF\PDFS
Warning: No writable tags set from C:/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
    1 directories scanned
    0 image files updated
    1 image files unchanged

Any thing that i'm missing or the PDF is now ilegible.

Regards and thanks

Phil Harvey

You should drop the "+" from the command or you will duplicate all of the keywords.

This should work provided your config file is properly activated.

What is the output of this command?:

exiftool -keywords -myname2 C:\EXIF\PDFS

If Keywords exists but Myname2 doesn't, then the config file isn't activated.  See FAQ number 11 for help with this.

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

seraosr

Hi Phil,
definitely, i've drop the "+". My mistake, in last post, i've write "+".
I think that duplicated keywords is because PDF file has writen on Keywords field and Exif write on XMP-dc Keyword.

The output for this command - exiftool -keywords -myname2 C:\EXIF\PDFS is:

C:\EXIF>exiftool -keywords -myname2 C:\EXIF\PDFS

======== C:/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
Keywords                        : Porto, Editora:, CESPI-REC_20000000_TXT.pdf
Myname 2                        : Porto, Editora:, CESPI-REC
    1 directories scanned
    1 image files read


I think that config file is activated, or if you prefer i can use "exiftool -config .ExifTool_config". I did the teste "print "LOADED!\n";" and the output is "LOADED".

Attached my folder "EXIF". Please unzip and paste on "c:\". Please, kindly execute command.

Regards and Thanks
Many thanks

Phil Harvey

So your config file is activated OK.  I tried this config file with the command and your sample PDF on my Mac and it worked fine.  It should work fine on Windows too, but I don't have a Windows system that I can try this on now.

You could try adding -v3 to the command with "-keywords<myname2" to see if it gives any hint about what is going on.

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

seraosr

Hi Phill,
i've a MAC either. I've followed the FAQ and i've configured on MAC, but isn't working neither.
Think that isn't writing back on PDF. Can you please analyze?

bash-3.2# cat ~/.ExifTool_config
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        Myname2 => {
               Require => 'Keywords',
               ValueConv => q{
                   my @list = ref $val eq 'ARRAY' ? @$val : ($val);
                   s/_\w+\.pdf//i foreach @list;
                   return \@list;
               },
        },
    },
);
bash-3.2# exiftool -keywords -myname2 /Users/rsoares/Desktop/EXIF/PDFS/ 
======== /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
Keywords                        : Porto, Editora:, CESPI-REC_20000000_TXT.pdf
Myname 2                        : Porto, Editora:, CESPI-REC
    1 directories scanned
    1 image files read
bash-3.2#


Thanks again.

Phil Harvey

Can you paste the output of this command?:

exiftool "-keywords<myname2" -v3 /Users/rsoares/Desktop/EXIF/PDFS/

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

seraosr

bash-3.2# exiftool -keywords -myname2 /Users/rsoares/Desktop/EXIF/PDFS/ 
======== /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
Keywords                        : Porto, Editora:, CESPI-REC_20000000_TXT.pdf
Myname 2                        : Porto, Editora:, CESPI-REC
    1 directories scanned
    1 image files read
bash-3.2# exiftool "-keywords<myname2" -v3 /Users/rsoares/Desktop/EXIF/PDFS/
======== /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
Setting new values from /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
Writing PDF:Keywords if tag exists
Writing MIE-Doc:Keywords
Writing XMP-acdsee:Keywords if tag exists
Writing IPTC:Keywords
Writing PDF:Keywords if tag exists
Writing MIE-Doc:Keywords
Writing XMP-acdsee:Keywords if tag exists
Writing IPTC:Keywords
Writing PDF:Keywords if tag exists
Writing MIE-Doc:Keywords
Writing XMP-acdsee:Keywords if tag exists
Writing IPTC:Keywords
Writing PostScript:Keywords
Writing XMP-xmp:Keywords if tag exists
Writing XMP-pdf:Keywords if tag exists
Rewriting /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf...
    - PDF:Keywords = 'Porto'
    - PDF:Keywords = 'Editora:'
    - PDF:Keywords = 'CESPI-REC_20000000_TXT.pdf'
    + PDF:Keywords = 'Porto'
    + PDF:Keywords = 'Editora:'
    + PDF:Keywords = 'CESPI-REC'
  Rewriting XMP
  Warning = [minor] Ignored empty rdf:Bag list for dc:creator
    - XMP-pdf:Keywords = 'Porto Editora: CESPI-REC_20000000_TXT.pdf'
    + XMP-pdf:Keywords = 'Porto, Editora:, CESPI-REC'
Warning: [minor] Ignored empty rdf:Bag list for dc:creator - /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
    1 directories scanned
    1 image files updated
bash-3.2#

Phil Harvey

OK, so this seems to have worked.  (the file was updated and the XMP and PDF Keywords were written.)

Now, on the updated PDF file, what does this command give?:

exiftool -a -G1 -keywords /Users/rsoares/Desktop/EXIF/PDFS/

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

seraosr

bash-3.2# exiftool -a -G1 -keywords /Users/rsoares/Desktop/EXIF/PDFS/
======== /Users/rsoares/Desktop/EXIF/PDFS/CESPI-REC_20000000_TXT.pdf
[PDF]           Keywords                        : Porto, Editora:, CESPI-REC
[XMP-pdf]       Keywords                        : Porto, Editora:, CESPI-REC
    1 directories scanned
    1 image files read
bash-3.2#


It's almost Phil, almost.

The Keyword added is: "Porto, Editora:, CESPI-REC". So, 3 keywords.
The Keyword that I need to be added is: "Porto Editora: CESPI-REC"

Cataloging to our DAM system, the result is 3 Categories with the 3 Keywords added. And the PDF is cataloged to 3 categories, so, 3 Records.

Categories Tree:

Porto (1)
Editora (1)
CESPI-REC (1)

And what we need to be cataloged is 1 Record on Subcategory: CESPI-REC on main Category "Porto Editora".

Categories Tree:

->Porto Editora
                     > CESPI-REC (1).

Phil Harvey

I don't understand.  If you just tell me the keywords in the original file and the keywords you want in the final file, then I can help.

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

seraosr

Keywords on the original file are: "Porto Editora: CESPI-REC_20000000_TXT.pdf" - One Keyword
Keywords that i want in final file: "Porto Editora: CESPI-REC" - One Keyword

But, i want that "Porto Editora: CESPI-REC" be one keyword only and not three.

This is what i get
    + XMP-pdf:Keywords = 'Porto, Editora:, CESPI-REC'

This is what i want (Without commas, one keyword only)
    + XMP-pdf:Keywords = 'Porto Editora: CESPI-REC'

Thanks

Phil Harvey

I see the problem.  The PDF keywords are split up into separate keywords by exiftool because these are often stored as a  simple string.  So all you need to do is force ExifTool to use the XMP:Keywords instead of the PDF:Keywords in your config file by adding "XMP:" to the Require'd tag name:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        Myname2 => {
               Require => 'XMP:Keywords',
               ValueConv => q{
                   my @list = ref $val eq 'ARRAY' ? @$val : ($val);
                   s/_\w+\.pdf//i foreach @list;
                   return \@list;
               },
        },
    },
);
...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 ($).

seraosr

No. You saw the solution. Thank you very much for your help. Wasn't easy. Good to have MAC OS X (snow leopard)

By the way, I've tested on Windows and doesn't work, even with this last changes.

Exif tool is very powerful, was amazing if sintax were more not to complex.

Thank you very much for your hard work. Really!