GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Script to Populate Summary Properties

I am looking for a means within Opus to populate the "comments" field in all files within a directory with the File Path + File Name.

The files within this directory will undergo substantial renaming and I want to retain the original File Path + File Name so that an end-user may search on this information.

Any help greatly appreciated.

Opus can't do this itself, but the descript.ion file format is pretty simple (just filenamecomment), so you could probably make a button to generate that fairly easily.

(e.g. something like:

@nofilenamequoting
echo >> descript.ion {file} {filepath}

You can have Opus log the rename actions and then save the log to a text file that has the old and new names in it.

If you want to do that, you should make sure Opus is set to log "Rename" and "include all files renamed by wildcards" under Preferences -> Logging. Also make sure the maximum number of events is high enough to capture all of your filenames (plus some extra for any other commands which get logged before you save the data to a text file).

Saving the log can be done via Tools -> Output Window, on the Log tab.

Do a test run on some dummy files first to make sure everything is working as you wish.

Here's another thread with a similar question where there are a few other thoughts that might be useful:

I would like to reserve the use of "Descript.ion" for another purpose.

By placing the FullPath "onboard" each file as metadata, we are sure to keep this straight. I considered using the "rename log" and discounted this as an option as it will be very easy to make a mistake.

The best way to do it is to insert the FullPath value into a metadata field within each file ... "comments" is large enough.

Too bad that DOpus cannot use a variable {Filename} to search and replace the "comments" values for the files.

I tried to see if you could just pass the info you want from Opus to a vbscript, but it seems Microsoft still hasn't implemented a native OS mechanism to SET extended file properties like the ntfs Keywords and Comments summary fields via script...

There's an old COM object extension you can install called Dsofile that you can download, install, and then utilize in vbscript in order to SET some of those field values though...

If you're interested, it would be pretty trivial to write a script, and then send the file info you want to it from an Opus button/hotkey/contextmenu/whatever to have the script write the data for you...

One thing I'd caution you on though... be wary of apps that save updates made to files as NEW files when hitting save :wink:... as those copies would probably NOT retain the metadata from the original file... while testing out Dsofile quickly against the very script running the actual code, I found that my editor (UltraEdit) was saving off the original version of my script (as I like it to) and the "updated" version no longer had the comment I was expecting to see in my code output... :slight_smile:.

I also suppose you could even abuse the rename script feature in Opus to execute the code to update the Comments property field in order to not even have the script be an 'external' vbs file...

I was farting around with this anyway... so, see if this works how you want it.

Assuming you're in Details view mode, add the Comments field from the Documents column collection to see the results of running the script...

Then:

<?xml version="1.0"?>
<button display="both" icon_size="large" label_pos="right">
	<label>Test Button</label>
	<tip>Test Button</tip>
	<icon1>#pathfield</icon1>
	<function type="normal">
		<instruction>Rename {f} PRESET=comment </instruction>
	</function>
</button>
  • Unzip the comment.orp file from the attached zip file... it's am Opus rename preset file which you'll need to 'Import' via your Opus rename dialogs File->Import menu (screenshot attached)...

Then, just select a few files, click the button... and provide some feedback.
comment.zip (585 Bytes)

NOTE: I just noticed that simply IMPORTING the preset file seems to actually execute the script against any file(s) selected, and indeed modifies the Comments the file(s). I wonder if that's "expected" behavior. I'd have thought it should only 'actually' run from clicking 'Ok'...

Just an observation - I'll report it to GPSoft...

That's normal. Note the preview list that's turned on at the bottom of the rename dialog in your screenshot. In order to update that Opus has to run your script to find out which filenames it will generate for the selected files.

If your rename script has side effects, and doesn't just pass back a new filename to Opus, then those side effects will be triggered.

I suppose rename scripts could be passed a flag telling them it's only a test, but rename scripts weren't really designed with side effects in mind.

You can avoid the problem, while still "abusing" rename scripts, by putting the script into a button instead of into a rename preset (like this). That reduces clutter in the rename dialog's preset list, too.

(I've added a note about this to the post about the technique.)

Aha... yeah, I thought about that afterwards and just tried it with the preview pane turned off, and sure enough that's it... okey.