Inserting filename in metadata

Hi, newbie here.
I'm about to rename a lot of camera files according to my new naming system. However I want to retain the ability to find an image by searching for its original filename. Clients sometimes come back to me after a long time and request a print by its filename as it was way back when.
The solution I'm proposing is to store the original filename in the files IPTC metadata. Then after renaming files I can use a cataloguing program (Whereisit in my case) to search for the file with that name as one of its keywords.
While the DOpus help file makes it clear how I can use metadata to form part of all of a filename, it's not clear to me how to do the reverse: how to store the filename as part of the metadata.
Any ideas? If I can do this, it will future-proof my files against being lost through careless or intended renames.
Thanks guys
Robert
Melbourne, Australia

To put filename in comment field:
SetAttr META comment:{file}

Of course, you can change field by another...

gpsoft.com.au/help/opus10/de ... r_META.htm

That works just great! Thanks guys, you've made my life easier and helped me to learn a lot about this excellent program
Robert, Melbourne

I spoke too soon guys. I'm not there yet. When I select multiple files and apply the setattrib command the metadata of only the first file is written.
Is it possible to apply this to multiple files? I dearly hope so as I have ten years of camera files I want to process.
thanks for your time
Robert
Melbourne

Maybe Leo can help you :wink:

If you don't specify a filename for SetAttr (and most other commands) to act upon then it will act upon all selected files. So SetAttr META comment:{file} would set all file comments to the first file's name (and then probably set them all to the second file's name and so on, since using {file} in the line will cause it to be run once for each file.)

In theory, this should work, but it doesn't seem to:

SetAttr FILE {filepath$} META comment:{file$}

However, this works for me, as a bit of a kludge:

@sync:dopusrt /acmd SetAttr FILE {filepath$} META comment:{file$}

(Edit: This includes some of the improvements mentioned below.)

Excellent... As always...

I don't know if there's a more elegant way to do it but this one is working for me (In the Command Editor "Function" must be set to "MS-DOS Batch-Function"):

@runmode hide
@externalonly
@nofilenamequoting

@echo off
set count=1
for /f "tokens=*" %%a IN ("{file}") DO (call :sub "%%a")
goto :eof

:sub
set file=%~nx1
for %%a IN ("{file}") DO (Start "" "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Setattr Meta="comment:%file%" FILE="%file%")
set /a count+=1
goto :eof

Edit the path to dopusrt.exe if you installed DOpus to a different location.

Edit: leo hit me with a better solution. :smiley:

Kludge smudge, I don't mind as long as it works and Leo's solution works for me. Thanks again guys for all your time.
Robert
Melbourne

Once again I find it's not as easy as it looks. When I apply Leo's clever kludge to write the filenames to the IPTC comment fields of many files, it works when applied to the files in one directory. However I have several sub-directories per month. I thus show via flat view all the image files in a year and try to write these filenames to the metadata by selecting all the files. When I do this DOpus crashes. Just stops with not even a cry for help.
Am I doing something wrong? The year I'm working on has only about 4000 files. I wait till the metadata window returns before selecting a file to see if the filename write was successful but perhaps DOpus needs more time.
Any suggestions will be much appreciated. Thanks
regards from Robert, Melbourne

What do you mean by "crashes"? Does the entire Opus process and all of its windows vanish? Or do you just mean that nothing happens when you run the button, no matter how long you wait?

To make the button work with Flat View, you need to change it so it passes the full path and not just the filename:

SetAttr FILE {filepath$} META comment:{file$}

(I also added the two $ which should have been there before. Those make the button not do anything if no files are selected, since it only makes sense when something is selected.)

That's a quick response Leo. Thanks. Sorry about the imprecise language. By 'crashing' I meant that all DOpus windows vanish. Not all processes stopped as I could restart by double-clicking the desktop.
I've applied the suggested fix but find it only writes the filename of the first-selected file. This was a problem I had in the beginning which was fixed with the first solution dopusrt /cmd SetAttr FILE {file} META comment:{file} you suggested. I hadn't told you that I intended to run this in flat view; my oversight. Perhaps the second 'flat view' solution needs tweaking like the first 'multiple file' solution needed?
By the way I'm using Opus 10.0.3.0.4392.x86 on XP Pro SP3.
regards
Robert, Melbourne

As a side issue Lea, the 'Apply' and 'Cancel' buttons never become active after I've written metadata. Could this be related to my other problem?
Robert

Sorry, you still need the dopusrt /cmd part, which I left out in my previous post:

dopusrt /cmd SetAttr FILE {filepath$} META comment:{file$}

Does that work?

Leo, your latest solution works but not entirely. I ran it on a selection of three or four files and it worked. When I ran it on a selection of 100 files it worked too. I then ran it on all jpeg files selected in Flat View and Opus 'crashed' again. i.e. All Opus windows closed without warning.
I note however that of the 4000 files visible in Flat View, Opus reports 91 hidden files. I can't see these despite 'Hide hidden files' and 'Hide protected OS files' being cleared in Preferences-Folder-Folder Display.
Could attempts to write metadata to hidden files cause the unexpected shutdown? And why can't I see these 91 hidden files?
I also get bogus files appearing that look like other files that have been renamed. For instance after carrying out the above operation on 100 files i see a file called SAM_0062.SRW.spd when there is already a file called SAM_0062.SRW. Or another time a file called SAM_0038.JPG.8424 when there's already a file called SAM_0038.JPG
These phantom files disappear when I refresh. Sorry to introduce what may be a red herring but I do so on the chance it may indicate if something's amiss.
I'm optimistic we'll sort this out soon Leo. It promises to bring big improvements to my work flow. Thanks for your time & patience.
Robert

As an aside Leo, do manufacturers' RAW files have the capacity to carry IPTC data? I refer to those from Canon and Olympus such as .CR2 and .SRW.
Robert

This is becoming quite complicated and time-consuming so if you want us to spend more time on it, please link your account to prove that you've bought Opus and qualify for priority support.

Account now linked. Thanks Leo
Robert

Thank you.

I've spent the morning looking in to this and I think I have worked out how to reproduce the problem (or something very similar, at least), but haven't tracked down the cause of it yet.

I think I have a workaround for you, though. This seems to prevent the problem for me (at least so far):

@sync:dopusrt /cmd SetAttr {filepath} META comment:{file}

(i.e. Add @sync: to the start of the line.)

Hopefully that workaround solves the problem for you, but I'll keep looking for the underlying issue as it shouldn't be happening in the first place.