DO Meta Wizard Command

Meta Wizard is a Directory Opus script add-in command that simplifies the task of editing metadata, allowing you to modify it by specifying a search pattern and replacing it in the selected metadata properties.

Master your files effortlessly as Meta Wizard swiftly finds and replaces metadata properties values in no time. Discover the magic of intuitive and efficient metadata search and replace!!!

Its main features are:

  • Support for almost all metadata properties editable by Directory Opus.
  • Easy selection of metadata properties to edit with search support.
  • Support for deleting metadata properties based on search criteria.
  • Support for pattern search using regular expressions, ignoring diacritics, matching whole words and case.
  • Extended file information can be used in the Replace field, with support for most DOpus metadata insertion codes (e.g. {file}, {date}, etc.), similar to the Advanced Replace dialog.
  • Preview the changes to be made for each file as you type.
  • Ability to make multiple changes and reuse the same window.
  • Easy to use, fully multilingual interface (in all languages supported by DOpus).
  • Automatic creation of logs, so you can track the changes made by the command and even undo them.
  • No interface mode, which allows you to make changes directly without showing the main window.

:warning: IMPORTANT: READ BEFORE PROCEED

This script is provided "as is" and without warranty of any kind.
It has been made during my spare time and has not been extensively tested, so it is presented as a testing version and should be used with extreme caution.
The user assumes full responsibility for its use and understands that the author is not responsible for possible failures or loss of data.
It is strongly recommended that files be backed up before using them with this command.
Any feedback on possible improvements or bugs is welcome.

Before You Begin

  • Re-read the notice above.
  • Read all the info about SETATTR information on this page. It is important that you know what kind of values (text, numeric, etc.) each property uses before you start playing with this command.

How to Install

Download the file below. Then go to Settings / Scripts (or run Prefs SCRIPTINSTALL) and select the downloaded file.

:warning: IMPORTANT: Needs at least DOpus v13.7.1

v1.2.0 : MetaWizardCommand.opusscriptinstall

Options

In the Script Management window, select Meta Wizard and click in Edit button.

  • log level : Logging level to be displayed.
    • OFF to show only errors.
    • DEBUG to show all messages.
    • STANDARD to show only the most relevant information.
    • WARNING to show messages that needs your attention.
  • Logs Path : Folder path where log files will be stored.
  • After actions : Choose what to do after the command has been completed.
  • Doc Exts : File extensions that will be considered as "true" documents (e.g. can have Author, Subject, etc).
  • Dialog Mode : Select the dialog's UI you want to use. Currently you can choose between 3 modes:
    Preview List on Left :

    Preview List on Bottom :

    Preview List on Right :
  • Preview List max column width : Maximum column width in Preview List. 0 to always autosize.
  • Properties List max column width : Maximum column width in Properties Sheet List. 0 to always autosize.
  • Find : Hotkey for Find Edit Control.
  • Replace : Hotkey for Replace Edit Control.
  • Metadata Filter : Hotkey for Metadata List filter.
  • Properties Sheet Filter : Hotkey for Properties Sheet List filter.
  • Case sensitive checkbox : Hotkey for Case sensitive checkbox.
  • Regular expressions checkbox : Hotkey for Regular expressions checkbox.
  • Whole words checkbox : Hotkey for Whole words checkbox.
  • Ignore diacritics checkbox : Hotkey for Ignore diacritics checkbox.
  • Global replace checkbox : Hotkey for Global replace checkbox.

Usage

You can use Meta Wizard with the selected files in the source Lister, by simply using MetaWizard.

The UI comes with 4 sections:

Pattern section : Lets you edit the search and replace strings. These values and the checkboxes below them are used to build the search pattern and its replacement.
In addition, the button allows you to insert references to other file properties in the replacement field, as well as a special keyword ({empty}) to clear the values in the selected properties in the Metadata List.

Preview section : Contains the Preview List, which is a list of all files used by this command. It also contains a column for each property selected in the Metadata List, showing the new calculated value in real time.
You can also select which files to apply the replacements to.
The number of pending tasks to be applied is displayed at the top.

Metadata section : Contains the Metadata List, which allows you to choose the properties on which to apply the search and replace. It has a filter for quick search. You can check/uncheck a property with its respective checkbox or by double clicking on it.

Property Sheet section : Contains a list of all properties (editable and not) for the file selected in the Preview List.
It also has a filter for easy searching. In addition, it allows you to apply certain filter settings by pressing the button.
Double-clicking on a property value activates the edit mode for the value (only useful for copying the selected value, it does not really edit anything).

The FIND, REPLACE, CASE, NODIACRITICS, NOGLOBAL, PROPERTIES, REGEX and WHOLEWORDS arguments allow you to prefill data in the UI, in the corresponding fields.

The Add and Apply buttons are activated when the Find and Replace fields have content and at least one property and one file are checked.
The Add button allows you to save in memory the changes currently made, and start a new replace task (NOTE : It does not make any changes to the files yet, for that is necessary to use Apply at the end).
The Apply button adds the current changes to the task list, and applies (saves the changes to the files) all pending tasks.
The Undo button is activated when there is at least one pending task. It allows you to undo the changes of the last saved task.

When using NOGUI, the main dialog is not shown, and values must be provided by the corresponding arguments (at least FIND,REPLACE and PROPERTIES must be present).

The script will generate 2 files in the folder of your choice (or in /profile\DOpus_F&RLogs) if any metadata changes are made.
The "Files" file contains the SETATTR commands run by the command.
The "Backup" file contains the SETATTR commands needed to undo the changes made (that is, using the original values). You can copy these commands (e.g. to a button) and run them if you wish to revert them.

Command Arguments

ARGUMENT TYPE DESCRIPTION
CASE /S Start the dialog with 'Case sensitive' checked
With NOGUI will be applied to the search pattern directly.
FILES /K/M Specifies the name of the file or files to use with this command.
If you don't provide this argument the command operates on all selected items in the source Lister.
FIND /K Set Find edit control content when starting the dialog.
With NOGUI will be applied to the search pattern directly.
NODIACRITICS /S Start the dialog with 'Ignore diacritics' checked.
With NOGUI will be applied to the search pattern directly.
NOEMPTY /S Disables edition for those metadata properties that are originally empty.
NOGLOBAL /S Start the dialog with 'Replace All' checked.
With NOGUI will be applied to the search pattern directly.(disables 'g' flag in pattern)
NOGUI /S Builds the pattern and applies the replace in the selected properties without showing the default UI
Must need that at least FIND, REPLACE and PROPERTIES arguments been used.
MULTI /S Used in conjunction with NOGUI to define multiples patterns. FIND and REPLACE can take a list of values, separated by commas, to apply several replacements at once (use a single quote ' to escape a comma if needed).
PROPERTIES /K Set metadata properties to edit when starting the dialog. Current valid values are :
tags, rating, usercomment, 35mmfocallength, album, albumartist, aperture, artist, author, bpm, cameramake, cameramodel, category, comment, company, composers, conductor, copyright, creator, datedigitized, datetaken, digitalzoom, directors, discnumber, encoder, encodingsoftware, exposurebias, exposuretime, fnumber, focallength, genre, gpsaltitude, gpslatitude, gpslongitude, imagedesc, initialkey, instructions, isospeed, lastsavedby, lensmake, lensmodel, orientation, producer, producers, publisher, releasedate, shutterspeed, software, subject, subjectdistance, title, track, year With NOGUI the replace will be applied to those properties directly.
REGEX /S Start the dialog with 'Regular expressions' checked.
With NOGUI will be applied to the search pattern directly.
REPLACE /K Set Replace edit control content when starting the dialog.
With NOGUI will be used to replace pattern matches directly.
WHOLEWORDS /S Start the dialog with 'Whole words' checked.
With NOGUI will be applied to the search pattern directly.

Good to Know

  • Meta Wizard is the spiritual succesor of my other script add-in Find and Replace Metadata.
  • The command will only try to write the properties that the file CAN have (e.g. it won't try to write album for a document file). So it's safe to choose mixed properties for the replacement.
  • The command, at the time of writing, only performs a check for some types of data (mostly numbers or properties that require a special syntax) to avoid unwanted behavior when actually setting the changes in the file. However, not all values are checked (dates por example), so again, use it carefully.
  • Please refrain from using it on hundreds of files at once when using the UI for the time being. Since the results are displayed in real time, there may be a delay due to the number of files.
  • In order to delete a property, use the {empty} keyword in the Replace edit control.
    • e.g. If you want to delete a property regardless of their content:
      Select the desired properties you want to delete from the list.
      Use in Find edit control : .*
      Use in Replace edit control : {empty}
      :ballot_box_with_check: Check Regular Expressions
  • Hotkeys can be set via Script Configuration.
  • The submenus when inserting extended information sometimes appear far away from the Replace edit control, this is expected. AFAIK you cannot create actual submenus and they are always displayed at the current mouse coordinates.
  • For multi values properties, the command automatically skips those who are duplicates.
  • Some files are recognised as Documents, even if they have only 1 or 2 general values of this type. And if you try to write a property not allowed in these files, DO will show an error. To avoid that, use doc_exts in configuration to define all the extensions you want to consider as "true" documents. If a file recognized as document doesn't have their extension registered in there, ONLY those properties already existing can be edited (like an NOEMPTY implicit for those files).
  • Some properties cannot be edited with this command, because they require a value that has a specific meaning. I will consider adding support for these properties in the future if there is a request.
List of unsupported properties
  • Contrast
  • Exposure program
  • Flash
  • Metering mode
  • Saturation
  • Scene capture type
  • Sharpness
  • White balance
  • Compilation
  • Cover art

NOTES / FURTHER DEVELOPMENT

  • Your feedback is important for possible improvements and bug fixes.
  • Some strings in the UI are showed in English/Spanish (depending on DO current language). If you want to collaborate with translation to your language, please contact me via private message.

Changelog

v1.2.0 (Jul 12, 2024) : MetaWizardCommand.opusscriptinstall (19.0 KB)

  • Added support for datetimeoriginal and datetimecreated values (read only).
  • Added support for minimize and maximize buttons in the title bar.
  • Other minor corrections
Full changelog

v1.1.0 (Apr 21, 2024) :

  • Now the dialogs uses the font name/size configured in Preferences / Colors and Fonts / Fonts > Dialogs.
  • Code updated/cleaned up.
  • Logging system improved.

v1.0.0 (Mar 10, 2024) :

  • Added MULTI argument, to perform several replacements in conjunction with NOGUI.
  • New Log Level added : STANDARD.
  • Minor corrections.

v0.9.1a (Feb 04, 2024) :

  • Fixed error when using NOGUI.
  • Fixed error with Abort button when setting metadata.

v0.9.0a (Feb 03, 2024) : Initial release

15 Likes

Powerful script, an all-terrain tool!!!

1 Like

A more than worthy follow-up to Find and Replace Metadata. I already have it installed. Well done, as usual.

1 Like

Update v0.9.1a (2024-02-04) :

  • Fixed error when using NOGUI.
  • Fixed error with Abort button when setting metadata.
1 Like

dear errante Thank you so much for the nice script. It's very useful to me. it's make DOpus more powerful. Great Job. Thanks Brother

1 Like

Fantastic script! Thanks

1 Like

Powerful script, does installing this mean I no longer need the Find and Replace Metadata script?

1 Like

I would say yes.

errante, what a very useful and handy script. I put it to good use in loading tags for NTFS filenames of images taken from Snagit tags of select screen captures. Made a very tedious job much, much less so.

My only suggestion is to have the existing Find clause (.*) show initially in the Preview screen, so that one can see its transformation as one applies a replacement string. A good illustration of this before & after shot is shown in the TGRMN's utility Bulk Rename Utility.

In any case, thank you for giving back to the community with such useful tools.

DaveM

1 Like

Is there a way to make a preset, that meets following requirements to enable 'mass meta wizarding'?

  • Set preset to work on tags only
  • have a list of tags to be replaced
  • have a list of tags that replace the entries accordingly
  • and, if possible, in NOGUI mode

Referring to following request:

And with your tool, it feels like i'm almost there. :+1: :slightly_smiling_face:

I had this updated version for my personal use. Try it and report back if it's working for you too.
MetaWizardCommand.opusscriptinstall (18.9 KB)

Then use MetaWizard FIND="䵳,鳀,䵣,䮫,䮤,䳥" REPLACE="äus,és,äuc,äum,änd,äse" MULTI PROPERTIES=tags NOGUI

FIND and REPLACE can take several values separated by commas (to use an actual comma escape it with '). You can change them if they are not correct. MULTI is important to distinguish between a single or multi task when using NOGUI.

2 Likes

Yes, that works very good indeed. Thanks a lot for providing this unofficial version. Only thing i have to do now is to prepare a much better list of all misspelled words, because the characters are so tiny and similar, that i have already some mistakes included. But once i have rebuilt the list, i guess the resulst will be perfect. Great work!

There is another nasty problem still. While i can replace the chinese characters, there are some placeholder style ones, that look like two squares. The problem is, that they actually have different spellings.

For example, in Br□□n it would be spelled 'Brücken' (bridges), but the word K□□randbr□□ is written as 'Köhlbrandbrücke', which are obiously very different spellings.

So, whoever screwed up that code which led to those results, did a great job at that :wink: :rage:. And the ominous □□ chars come even in many more flavors, for example V□□ (for Vögel/Birds), to make the mess perfect.

My suggestion would be, that you maybe could provide just simple placeholders, something like ?, which would act as a wildcard. Then i could literally tell MetaWizard, to interpret 'V??" as Vögel, or
'K??randbr?? as 'Köhlbrandbrücke', when doing the replace.

You can use regular expressions as well.

Sounds good. Could you give me a short example please, how the difference would look. Like V?? for Vögel or Weinst?? for Weinstöcke. In that case, i would make all problematic words using the regex, and wouldn't even bother to use the chinese chars.

Edit: just searching the web, but it's still a book with seven seals to me. :grin:

Not tested:
MetaWizard FIND="䵳,鳀,䵣,䮫,䮤,䳥,Br..n" REPLACE="äus,és,äuc,äum,änd,äse,Brücken" MULTI PROPERTIES=tags NOGUI REGEX CASE

1 Like

Thanks, i think you brought me on the right track. Please ignore my PM. I just have overlooked the most important detail in your hint, which is simply the '.', which seems to do the job!

:+1:

Works like a charm. I'm still extending the list, whenever i find new words. Some of them produce weird results (not by the script), mostly, when names are similar or variations, but there is an elegant way to solve it. I just take that malformed replacement string and feed it back into the same list, so the result will be right eventually. No second pass needed.

:slightly_smiling_face:

v1.0.0 (Mar 10, 2024) :

  • Added MULTI argument, to perform several replacements in conjunction with NOGUI.
  • New Log Level added : STANDARD.
  • Minor corrections.
2 Likes

:warning: IMPORTANT: Needs at least DOpus v13.5.1
v1.1.0 (Apr 21, 2024) :

  • Now the dialogs uses the font name/size configured in Preferences / Colors and Fonts / Fonts > Dialogs.
  • Code updated/cleaned up.
  • Logging system improved.
1 Like