Using a hash / # in a template not possible?

Started by yevev35775, December 05, 2021, 12:06:26 PM

Previous topic - Next topic

yevev35775

I have a template.fmt like this;

# File

app__CreateDate: $CreateDate
app__FileName: $FileName
app__FileSize: $FileSize

# Image

app__Aperture: $Aperture
app__FocalLength: $FocalLength
app__FocalLength35mm: $FocalLengthIn35mmFormat
app__ISO: $ISO
app__ShutterSpeed: $ShutterSpeed
app__ImageWidth: $ImageWidth
app__ImageHeight: $ImageHeight
app__Device: $Make
app__Model: $Model

# App

app__FileType: $FileType
app__Title: $Title
app__Keywords: $Keywords
app__Description: $Description


It outputs a .yaml file with all the required parameters, which is used as a sidecard for my photo's.

The thing is, that the #-blocks (# FILE / # IMAGE / # APP) are rendered like FILE / IMAGE / APP -> the # sign is removed by the exif-tool;

File

app__CreateDate: 2019:10:01 09:36:45
app__FileName: IMG_20191001_093645.jpg
app__FileSize: 1818217

Image

app__Aperture: 1.75
app__FocalLength: 4.77
app__FocalLength35mm: 26
app__ISO: 116
app__ShutterSpeed: 0.008
app__ImageWidth: 3264
app__ImageHeight: 2448
app__Device: Xiaomi
app__Model: Mi 9 SE

App

app__FileType: 1
app__Title: {#TITLE#}
app__Keywords: {#KEYWORDS#}
app__Description: {#TEXT}


I need that # sign, because in .yaml it is something like a divider-sign.

Any idea how I can keep it?

I tried escaping like \# '# `# and ## but that ends up in \ ' `

StarGeek

Put #[BODY] in front of those lines
#[BODY]# File

app__CreateDate: $CreateDate
app__FileName: $FileName
app__FileSize: $FileSize

#[BODY]# Image


* 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).

yevev35775

Quote from: StarGeek on December 05, 2021, 12:22:25 PM
Put #[BODY] in front of those lines
#[BODY]# File

app__CreateDate: $CreateDate
app__FileName: $FileName
app__FileSize: $FileSize

#[BODY]# Image


Interesting, that works perfectly.

#[BODY]# File becomes # FILE

So [body] and the 2nd # are removed, but the first one is still there.

Thanks for the answer!

Phil Harvey

@StarGeek:  Very smart.

This could also be done by changing "#" to "$hash" and adding -userparam "hash=#" to the command.

But there was an inconsistency in the original post.  The "#" lines should have been ignored, but yevev35775 stated that the "#" was removed and the rest of the line was output -- I don't see how this could happen.

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

StarGeek

Quote from: yevev35775 on December 05, 2021, 01:11:25 PM
#[BODY]# File becomes # FILE

So [body] and the 2nd # are removed, but the first one is still there.

Technically, it's the first hashtag that's removed.  You can test it by putting a space between #[BODY] and the second hashtag.  The output will have a leading space
* 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).

yevev35775

Quote from: Phil Harvey on December 05, 2021, 06:21:59 PM
@StarGeek:  Very smart.

This could also be done by changing "#" to "$hash" and adding -userparam "hash=#" to the command.

But there was an inconsistency in the original post.  The "#" lines should have been ignored, but yevev35775 stated that the "#" was removed and the rest of the line was output -- I don't see how this could happen.

- Phil

Not sure what you are meaning, but my template is like this;

# HEADER-1

Foo: $foo

# HEADER-2

Bar: #bar


This should output a sidecard for my photo's in the .yaml syntax, like this;

# HEADER-1

Foo: Hello

# HEADER-2

Bar: World


But since the # characters are deleted when parsing the template to the .yaml, it resulted in this;

HEADER-1

Foo: Hello

HEADER-2

Bar: World


So the # characters are gone, which I use for markdown purposes (where # = H1, ## = H2, etc...).

But this works fine;

#[BODY]# HEADER-1

Phil Harvey

With the format file you posted:

# HEADER-1

Foo: $foo

# HEADER-2

Bar: #bar


You should get an output like this:



Foo: Hello


Bar: #bar


Which is not what you indicated.

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

yevev35775

Quote from: Phil Harvey on December 06, 2021, 10:16:02 AM
With the format file you posted:

# HEADER-1

Foo: $foo

# HEADER-2

Bar: #bar


You should get an output like this:



Foo: Hello


Bar: #bar


Which is not what you indicated.

- Phil

You are correct, I made a mistake in my openings post.

Lines with a # are completely removed, since the tool thinks it's a comment.

But in my case it's not a comment, but a part of the markdown syntax.

I am glad you all helped me out.

Phil Harvey

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