Menu

Confusion how to use for Filenameextraction

2019-12-06
2019-12-09
  • Christian Schmidt

    Hi everyone,

    i tried to use the exiftool - but with not so much success.

    I need to extract the title and the description for the exif Data from the Filename.
    I have a Folder filled with jpgs named in a specific Pattern, for example 123AB_-12AB-23BD-34DE

    I would like to use everything before the _- as Title and everything after as description.

    I would prefer a solution using Windows (found some VBA code but didn't get it up and running) but any other solution (Linux etc.) would help too, even if I have even less knowledge of Linux ;)

    Would really appreciate your help!

    Christian

     
  • Phil Harvey

    Phil Harvey - 2019-12-06

    Hi Christian,

    Try this from the cmd.exe command line in Windows:

    exiftool "-title<${filename;s/_-.*//}" "-description<${filename;s/.*?-_//}" DIR
    
     

    Last edit: Phil Harvey 2019-12-06
  • Phil Harvey

    Phil Harvey - 2019-12-06

    ... but that will leave the file extension in the Description. Try this if you want to remove the extension:

    exiftool "-title<${filename;s/_-.*//}" "-description<${filename;s/.*?-_//;s/\.[^.]*$//}" DIR
    
     
    • Christian Schmidt

      Hi Phil,

      thank you so much for your Support.

      The Title works just fine. Unfortunally the description always uses the full file Name?! (from Start to End in both cases, just without the extension in the second case)

      I tried to understand the syntax of the filename filter, but it seems there is something wrong in my version:

      As the Title works like a charme i thought that "-title<${filename;s/_-.//}" means: <${} variable, s/ search, _- the searched string, ,// everything before the searched string?

      So i tried the following:
      "-description<${filename;s/-_//;s/.[^.]$//}"
      then I get an syntax Error for filename

      Unfortunally i can't find an Documentation on the filenames Syntax to test it further by my self.
      Could you lend me a hand?

      Kind Regards

      Christian

       
  • Phil Harvey

    Phil Harvey - 2019-12-09

    Hi Christian,

    Right. My mistake. Change the -_ to _- in that argument.

    Google for "Perl regex" for all the details about the syntax.

    And thanks for the donation!

     

    Last edit: Phil Harvey 2019-12-09
    • Christian Schmidt

      Hey Phil,

      oh, now I feel a little dumb - i transferred the -_ also :-D

      Thank you so much, it works like a charm!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.