Writing file name to metadata

I'd use the tags field with a syntax like oname:"the original filename.img".

I think I would use the Comment field - providing your digital asset management software can read that field.

Perhaps a little a little VB macro could pick up the filename from original file and pop it in the Comment field. You could run the macro against all your pics and then rename in safety.

Hmm...

In the meantime I am not sure what the exact question is. Is it..
Which field to choose? or..
How to do it? or..
both? o)

Sorry about the ambiguity. I don't mind which field is used but I don't know how to write a script to extract a file's name and write it to metadata.

Maybe one of these commands is all you need? You need to wrap them in a button of course.
SetAttr SETDESCRIPTION "{file}"
SetAttr META=tags:+oldname:'{file}'

That was quick tbone; thanks. Now it's to the DOpus manual to learn how to set up a button. It's about time I learnt such stuff.
Robert

It didn't take long. I've got my button and it works well, putting the existing file name as a tag in the extended properties group. Thanks again.

Oops, I spoke too soon. When I apply the store-in-metadata button to a selection of files the file name of the first file in the list is stored in metadata of every file in the list. To make the button work I'd have to apply it to one file at a time.
Does anyone have an idea why this is and how to get around this?

This was posted by Naki and should do what you want.

@nodeselect 
@sync:dopusrt /acmd SetAttr {filepath} META comment:{file|noext}

While testing, I noticed on .txt files, it does write to the Extended Properties: Comments field


but it does not display in the column.


Using DO12.0.11

I actually don't see why using just {file} would add the name from the first file to comments/tags of other selected files.
Is that how it's meant to work in DO? Is there a proper way around that?

Anyway, the following does not suffer from the unwanted behaviour:
It should be noticeably faster for few or many files too compared to using the external "dopusrt.exe" (needs button of type script, jscript):

function OnClick(data){
	var f = data.func, c = f.command, tab = f.sourcetab, sel = tab.selected;
	for(var i=0;i<sel.count;i++)
		c.RunCommand('SetAttr FILE="'+sel(i).realpath+'" META="tags:+oldname:\''+sel(i).name+'\'');
}

The SetAttr command works on all selected files by default, so the command is parsed one (for the first filename), passed to SetAttr, which runs on everything leaving no files selected for subsequent runs.

If you give the command the name of a specific file to work on (as your script is doing) then it should work.

I tried the above, the @nodeselect / @sync command whilst also using DO12.0.11.
Noticed that existing descriptions are not overwritten, text is added.
Wonder whether overwriting would be possible.

BTW when I restore the same files from a backup, the overwrite warning does not show that the 'new' descriptions in the new files (with ones with updated descriptions)

=

Thanks ktbcrash. My search had missed Naki's contribution. I see that the data written to the Comment field of Extended Properties does in fact show up in the Lister's column (Documents - Comments). See attached screen shot.
One advantage of tbone's solution is that it appends the file's name to the Tag field rather than overwriting existing Comments as your script does. Appending provides a history of file name changes. I may start with a raw file from the camera, rename to TIFF for post processing and rename again to jpg for distribution. This is a nice touch. For this reason I've modified your suggestion a little to include the file's extension in the metadata.
Does anyone know how to change this so that the Comment (or Tag) is appended instead of overwritten?
Thanks in advance
Robert




P.S.
Displaying the Comments field in a column of a Lister displays data only for image files. In my testing it displays data for jpg and TIF but not for ARW (camera raw). Puzzling.
Robert

Thanks for the tip (about Comments)
In the screenshot earlier this thread I got the impression it was in the description.

Am a bit confused.

Did the same on a photo and some files.

got the below (note 2 descriptions)

Comments: rightclick column ->Documents->Comments
Description:

=

Thanks for the tip (about Comments)
In the screenshot earlier this thread I got the impression it was in the description.

Am a bit confused.

Did the same on a photo and some files.

=

Using tbone's script the file name was written to the Tag field. Using kbtcrash's suggestion it was written to the comment field but not when the file is a raw. With raw files no data is written to the comment field.
You're not the only one confused. I'm sure the 'Invalid EXIF text encoding' message is significant.

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>