Can FilenameFormatString expand $Tag ?

Started by Luuk2005, October 06, 2020, 11:30:18 AM

Previous topic - Next topic

Luuk2005

Greetings experts! Sorry Im not explaining well, so this is trying to be very exact....

-Tagsfromfile ACCEPT  "Filename|FilenameFormatString|@" as "SourceFile" ??

FilenameFormatString ACCEPT         "Text" or "Text with variables like %d%f%c%e" but
FilenameFormatString NOT ACCEPT                "Text with ${Tag;Changes;}"               (except to be literal)

Is there secret way to make -Tagsfromfile "FilenameFormatString" expand ${Tag;Changes;} like %$Tag?
This because Im like: Tag=filename and Changes=s/find/replace/ because the cropping of %f is not always to be exact. Im not expert to invent any ways for exiftool to conduct the exansion, always FilenameFormatString wants $Tag to be literal. Im studying in the manual, but so far not find any examples much like this one.

Also, is it illegal to post link to the other forum, when it uses exiftool instead. Im often try helping on the other forum, because many times the application ignores metadata.  Many people prefer this, because the more it reads, the slower and slower it always keeps getting. So instead of asking for update, often there can be exiftool solutions.

The problem is most are prejudice to command-line, and seem to have problems in "GUI", so they never come here to the experts. So then Im trying to help, but often can make mistakes, and its illegal to edit the post. Im thinking its much better solution to ask the problem here, with link if not illegal. This not happens very often, so I promise its not like to be spam.
Thanks much in advance!
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Phil Harvey

Quote from: Luuk2005 on October 06, 2020, 11:30:18 AM
Is there secret way to make -Tagsfromfile "FilenameFormatString" expand ${Tag;Changes;} like %$Tag?

No.  The only control you have are the filename format codes (like "%f") and their substring features.  But to do what you want you could create a set of hard links with names set by ${Tag;Changes} and a targets that are accessible using FilenameFormatString.  See the HardLink tag for more information.

QuoteAlso, is it illegal to post link to the other forum, when it uses exiftool instead.

Sure!

- 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

It's hard to tell because you don't give any actual examples, but you may be making Common Mistake #5c.  Any time you're assigning one tag to another, you have to use the less/greater than signs </>, not the equal sign =.  You can mix the percent tokens with tag names, as shown in this example, as long as you use a the correct form.
* 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).

Luuk2005

#3
Greetings and many thanks!
Im not aware of the hardlink tag, so this can be very useful. Is there also way specify hardlink target??
Always target wants to be InputFile, but Im like very much for the hardlink redirect to ${Tag;Changes}.

Im sorry for misunderstanding, in the beginning I should have entered this instead..
-Tagsfromfile "Sourcefile" -MoreOptions "InputFileSpec"       (where Sourcefile=Filename|FilenameFormatString|@)

Im prefer FilenameFormatString because input-files are like  "SomeTextDesiredPartOfSourceFilenameMoreText.ext"
But its unfortunate because input-files with "SomeText" and "MoreText" is not always the same amount of characters, so Im not can crop with substrings.
Only ${Filename;s/find/replace} is to be reliable. The hardlink tag works if only we can set the target, else it conducts like -TagsFromFile @.
Again, Im very sorry for the bad explanations without example, and many thanks for the great support!
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Phil Harvey

The hardlink could work like this:

1. Make hard links to each file with a name that makes it easy to reference from a  -tagsFromFile argument (ideally, with the same name as the file):

exiftool "-hardlink=tmp/${TAG;EXPR}" SRCDIR

2. Run your -tagsfromfile command, using the hard links to reference the files you wanted (here I assume that you gave the links the same name as the file you wanted to copy the metadata from).

exiftool -tagsfromfile tmp/%f.%e ... DSTDIR

The above combination gives you effectively the same result as this command would, if it was possible (with the value of TAG taken from the SRCDIR file):

exiftool -tagsfromfile "SRCDIR/${TAG;EXPR}" ... DSTDIR   (won't work like this)

This will work if you can construct the name of the destination file from tags (including FileName) of the source file.

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

Luuk2005

Yes, it can work like this! Im not think to use -execute to first make the hardlinks, but kept trying in only one command.
Thanks very much for your patience and understanding.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7