Copy filenames into description

Part of my workflow for photography is to quickly get the files online for viewing and downloads. later, when I have the time I process them and rename them. People will look at the original galleries and tell me they want this one or that one. I can then quickly search for the filename on that date and get it. However once I edit the photos, I like to rename them. Making it hard or impossible to quickly find them again based on their original names.

What I would like to do, if it is possible, before I rename them, copy the original file names to the description or some metadata field somewhere that can be saved after a rename. Preferably in a way that I can search for it. But if searching is not possible, then I can at least have the description column visible and then scroll down until I find the one I want to get.

The original files are .CR2 (canon raw) files. Whatever changes are done need to be in a way that DO can read if I move the files to another computer and use DO on my other computer to do the same thing.

I am not so good at programming, so while this may be scriptable, I would not have any idea on how to do it.

You can use this to put files' current names into file comments:

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

Note that, at least for .CR2, these comments will not modify the files themselves. They'll be stored in NTFS ADS, which is metadata stored next to the file in the filesystem. That means the drive the file is on needs to be NTFS for it to work, and the data may be lost when other software* modifies or copies the files. Copying the files to removable drives, cloud storage, or into archives will almost always lose the NTFS ADS data. NTFS network drives are fine, but any other kind won't keep the data. So this may not be suited to all workflows.

(*Or Opus itself, if it isn't configured to copy NTFS ADS/comments under Prefs / File Operations.)

I'm not sure how ExifTool's CR2 support is, but you might be able to make an Opus button which uses it, or something similar, to add the comments into the CR2 files themselves, instead of as NTFS metadata. That would avoid all of those problems.

(As far as Opus itself is concerned, CR2 is a read-only format. We don't really want to open the can of worms of editing undocumented and frequently-changing raw camera file formats. It seems risky to us and could corrupt the master versions of people's photos. But people writing dedicated photo editing tools may feel differently, and may be on top of that domain enough that you can trust their tools to edit CR2 files.)

I will give that try and see what happens. I do not want to edit the actual file itself because I wish to keep the file unchanged and any tampering could cause other problems.

My Drives are all NTFS (external) and I do not sync these files on the cloud. I will sync one drive to another from time to time as a backup.

Shall I assume that there is no way to "search" the description column? via the search bar or filter bar?

as for the prefs.... do both options need to be enabled? Is that what you were talking about

image

Make sure the tool you use to do that will preserve NTFS ADS. Not all do.

You can search descriptions via Tools > Find Files > Advanced.

That option only affects whether or not the timestamp is changed. The option for copying the metadata is Preferences / File Operations / Copy Attributes / Copy metadata (comments, keywords, etc).

For those brave enough to edit raw files:

exiftool.exe "-usercomment<filename" -@ {allfilepath|filem}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Copy Filename to Comment</label>
	<icon1>#newcommand</icon1>
	<function type="batch">
		<instruction>@nodeselect</instruction>
		<instruction />
		<instruction>exiftool.exe &quot;-usercomment&lt;filename&quot; -@ {allfilepath|filem}</instruction>
		<instruction />
		<instruction>pause</instruction>
	</function>
</button>
How to

How to use buttons and scripts from this forum

1 Like

it works great.. thanks!

one thing i noticed is....

  • ran button with files on a network share.... worked great
  • it seemed to create a file descript.ion
  • i copied a file from there to my local computer
  • description copied... great
  • no descrip.ion created

is there a reason why that file was originally created... and then why it was not created when i copied the file to the new location.

Is the network share NTFS?

yes it is.

If descript.ion files are enabled in Preferences then I think they'll be used instead of NTFS metadata in all cases. They'll also only be created a little while after changes happen, or possibly after changing folders, to avoid updating the files too often.

You can use File > Exit Directory Opus to force any pending changes to be written out right away when testing what's happening. Try doing that, then go back to the folder. Is there a descript.ion file there now?

i went back to the folder and it was now created. Does that mean that if I use Windows Explorer to copy a file it will not know what to do with the descript.ion file and ignore the description when copying?

Explorer and most software won't do anything with descript.ion files.

You can turn descript.ion support on and off in Preferences. I think it's off by default.

Is there any benefit to going with descript.ion versus saving the comments to NTFS directly? I tried both ways and both work. Obviously if i copy outside of DO, the data is not preserved, but other than that is there a compelling reason to keep the descript.ion way of doing this?

descript.ion is mainly supported because it's a semi-standard that some older apps also use. If you don't have anything else that uses that format then NTFS is usually a better option. Neither way is perfect.

i decided to use the NTFS method... and ran into a problem... I often have to run this command on a few thousand photos at a time. Inevitably DO will crash. I get an error 0xC00000005 occurred in thread dopus_funtion at address 0x00007FF7747AF692.

When this happens, I need to end task DO. However, because it crashed, whatever files it was working on are messed up. What seems to happen is that the files are renamed to something strange like filename.123545 and then they go back to normal when the command is completed. However, when DO crashes, those files are left named like that. usually these files are a duplicate of what was there before, so it is safe to delete them. Except, there are times when I will be missing files at the end of it all. Luckily I have a copy and i am ok, but not sure why it is crashing. I am running this on a brand new machine.

If i run that command in smaller batches, of lets say 150 at a time, then it seems to be fine. It still does that funky renaming thing, (i notice this after the DO progress indicator has completed) and then it goes back to normal. But when I have thousands of images in a folder to do at once, doing it 150 at a time is not really the way to go.

I have also tried to run this on CR2 files on a network drive. It has never crashed that way, only on JPGs on the local computer. However, with the CR2 files, often it misses some. The CR2 files are in child directories, so i set it to view in flat mode then run that button. So I have to sort the folder by description and then run the command again on those it missed. I am not sure why it missed some and not others.

Are any crash logs created? Automatic crash logs (for bug reports)

I emailed it as requested and linked this forum's post

thanks

I just ran the command on 300 images... the progress indicator finished, but I am seeing all the files being renamed and then back to normal... and it is taking a really long time to finish. It is as if the command is running faster than the computer can handle. It is strange.

dopusrt won't wait for commands to finish so if you run the command that was above in the thread on a huge number of files, it will potentially run it on all of them at once, in parallel. You may be running out of memory or some other resource in that case, which would also explain the crashes.

Doing it on smaller batches is probably best.

This isn't ideal, obviously. You could do things better using a script, but it would be more complicated. Using dopusrt for this was always a quick kludge to provide an easy way to do this, but it may not scale to a large number of files.

As I have no idea how to script, I will have to do it in small batches. Even in small batches it takes ages to do, so I have to decide if it is worth the effort.

For those not brave enough to edit raw files :wink:

// https://resource.dopus.com/t/copy-filenames-into-description/37819/20

// 2022-08-23: log panel opens/closes automatically; processed files get temporarily deselected

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;

    cmd.RunCommand('Set UTILITY=otherlog');

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();

        cmd.RunCommand('Select PATTERN="' + item.name + '" DESELECT');

        var cmdLine = 'SetAttr FILE="' + item + '" META "comment:' + item.name + '"';
        DOpus.Output(cmdLine);
        cmd.RunCommand(cmdLine);

        cmd.RunCommand('Select PATTERN="' + item.name + '"');
    }

    cmd.RunCommand('Set UTILITY=off');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Copy Filename to Description</label>
	<icon1>#setattr</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/copy-filenames-into-description/37819/20</instruction>
		<instruction />
		<instruction>// 2022-08-23: log panel opens/closes automatically; processed files get temporarily deselected</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    cmd.RunCommand(&apos;Set UTILITY=otherlog&apos;);</instruction>
		<instruction />
		<instruction>    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {</instruction>
		<instruction>        var item = e.item();</instruction>
		<instruction />
		<instruction>        cmd.RunCommand(&apos;Select PATTERN=&quot;&apos; + item.name + &apos;&quot; DESELECT&apos;);</instruction>
		<instruction />
		<instruction>        var cmdLine = &apos;SetAttr FILE=&quot;&apos; + item + &apos;&quot; META &quot;comment:&apos; + item.name + &apos;&quot;&apos;;</instruction>
		<instruction>        DOpus.Output(cmdLine);</instruction>
		<instruction>        cmd.RunCommand(cmdLine);</instruction>
		<instruction />
		<instruction>        cmd.RunCommand(&apos;Select PATTERN=&quot;&apos; + item.name + &apos;&quot;&apos;);</instruction>
		<instruction>    }</instruction>
		<instruction />
		<instruction>    cmd.RunCommand(&apos;Set UTILITY=off&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>
2 Likes