Writing file name to metadata

thanks. I am talking about .jpg files.
regretfully enough I have no idea how to apply the script.

@jon
Thanks for the details regarding SetAttr and the details about how the FILE parameter changes what {file} is resolved to.
Hope to remember that the next time. o)

@opw62
The script snippet is meant to be used in a script button.
Copy and paste the following button definition onto any toolbar while in customize mode and you end up with a working button.

<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
	<label>SetMetaTest</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(data){</instruction>
		<instruction>	var f = data.func, c = f.command, tab = f.sourcetab, sel = tab.selected;</instruction>
		<instruction>	for(var i=0;i&lt;sel.count;i++)</instruction>
		<instruction>		c.RunCommand(&apos;SetAttr FILE=&quot;&apos;+sel(i).realpath+&apos;&quot; META=&quot;tags:+oldname:\&apos;&apos;+sel(i).name+&apos;\&apos;&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

I'm not getting very far at all so I'd like to summarise my position in the hope someone can help:
The script I'm using is:
@nodeselect
@sync:dopusrt /acmd SetAttr {filepath} META comment:previousname:{file}

This puts the file's name in the User Comment field (see grab) but EXIFtool reports 'Invalid EXIF text encoding for User Comment' (see grab). My DAM software IMatch doesn't find any data in this field. IMatch requires UTF-8 encoding for metadata.
The script is not able to write the file's name to metadata of camera raw files (see grab). I've tested the script with jpg and TIF. It works and presumably will work with other image files.
My questions:

  1. How do I write metadata without causing an invalid encoding error?
  2. How do I write metadata to camera raw files?
  3. How do I append the file's name to the Comment field rather than overwriting the existing comment? I want to have a history of file name changes.
    Thanks in advance for your time,
    Robert





tbone, what I wrote in my last post applies also to the script in your last post of Wed Aug 10, 2016 11:25 am
robert

@tbone
Thank you very much. Noticed changes.
File: Christmas Tree 2015.JPG
after applying the script:
IPTC Core Keywords read: oldname:'Christmas Tree 2015.JPG'
under ExifToolGUI it is listed under XMP

Many thanks again.

=

Hi opw62,

Can you please post what you final solution/code was to get the results in your last screenshot? I would like to do the same via rename tool using JScript but also add the original modified and created date to the description as well. Will see how far I can get... Thanks!

You may wish to use the script from tbone above.
Probably that will work.

=

It does!
8 years later thank you tbone! The fact that I've not come across anything newer suggests that it is still the way to go.