Bulk Meta

image

About:
This Script AddIn adds a new command, BulkMeta, to DOpus. It started life as Image Meta but has been enhanced to deal with additional file types.

This command opens a dialog which allows a number of editing options (Find & Replace, Append, Prefix, Replace, Clear, File Name and Parent Name) for several file types (Images, Audio and PDF).

Caution: There is no undo function. By default, all files will be backed up prior to any metadata being written. Backups can be located in the recycle bin once the script dialog has closed.

History:

Older History
  • 1.0 (14/5/20)
    • Initial Release.
  • 1.0.1 (15/5/20)
    • Added: Tags metadata to all categories.
    • Added: Popup menu to file list.
    • Added: Double click an item in the file list to use the filename in the edit box.
  • 1.0.2 (15/5/20)
    • Added: new options to popup menu.
    • Added: new config option to toggle confirmation dialog when writing metadata.
    • Fixed: Initial right clicking of an item in the listview would fail.
    • Fixed: Display error when changing modes.
  • 1.0.3 (16/5/20)
    • Fixed: Logical error identified and resolved by @SBond - thanks.
  • 1.0.4 (16/5/20)
    • Added: From a suggestion by @Leo, optionally, now backs up all files prior to writing metadata.
  • 1.1 (17/5/20)
    • Added: Open/Show, Copy to, and Properties to popup menu.
    • Added: Default double click configuration - Show, Open, Properties or Use Filename.
    • Added: Configuration option copy_folder - destination of "Copy to ..." option in popup menu.
  • 1.1.1 (17/5/20)
    • Added: Optionally log all metadata changes to a text file.

Current Version:

  • 1.2 (19/5/20)
    • Added: Log Reader dialog for easy viewing of the log file.
    • Changes made to the log file format to allow for parsing in the Log Reader.

Installation:

  • Download: Bulk Meta 1.2.js.txt (47.0 KB)
  • Drag the .js.txt file to Preferences / Toolbars / Scripts.

Usage:

  • Download: Bulk Meta.dcf (259 Bytes)
  • Select "Settings / Customize Toolbar..." from your Lister and then drag the button file to any toolbar you like.

Select as many files as you would like and click the Bulk Meta button. The script will sort through all selected files and only include valid filetypes based on the command line arguments you used. If no arguments are given, the dialog will open showing only Images and the dialog will be in Clear mode.

You can change Categories after the dialog has opened - the script will re-read the list of selected files and import only those matching the new category. Once you've finished making your edits, click Ok to save the changes. Cancel will close the dialog and write nothing to your files.

The script has several configuration options in the Preferences / Toolbars / Scripts page:

  • log_changes: Write a log file detailing all metadata changes made.
  • log_folder: Destination folder for the log file.
  • backup_files: Backup the files before writing any metadata.
  • confirm_write: Asks for confirmation before any metadata is changed.
  • copy_folder: Destination folder for the copy to function.
  • dblclk_action: Choose the default action for double clicking files in the list.
  • remember_position: The dialog will remember it's last used size and position.

If backup_files is set to true then when you click Ok to write your metadata changes, the script will backup all files to a new folder in /temp. The new folder will be named: .bulkmeta and will have the date and time appended. This folder will be deleted once the script is complete, leaving your backup in the recycle bin.

Optionally, a log file can be created detailing all metadata changes made. This log file will be appended with subsequent uses of Bulk Meta, leaving a permanent record of your usage (each time the log entries will be prefaced with the Date and Time). The log file will look like this:

----------------------------------------
Bulk Meta Log - 2020-05-17 19:26:25
----------------------------------------
Filename: Img_0184.jpg
Old Subject : Test Subject 1
New Subject : Test Photo 1

Filename: Img_0269.jpg
Old Subject : Test Subject 2
New Subject : Test Photo 2

Double clicking a file in the list will launch the action selected in the script configuration. Possible options are:

  • Show with DOpus Viewer - forces the DOpus viewer to show the file.
  • Default Open action - this acts as if you double clicked the file in the lister.
  • View Properties - show the standard properties dialog for the file.
  • Insert File Name - inserts the file name into the edit box (same as previous versions).

The popup menu which will show when you right click on a file in the list looks like this:

dopus_fBBlyxpf66

Most options here are self-explanatory. The list contains a number of items whose name will change dynamically depending on the current metadata being shown, for example Insert Current Subject will become Insert Current Title if title metadata is being shown.

The Copy to option will also show the configured destination folder in the menu. This function will just copy the file, unmodified, to the destination folder.

The script adds the "BulkMeta" command to DOpus and it accepts a number of arguments.

ARGUMENT  TYPE  POSSIBLE VALUES  DESCRIPTION

IMAGE      /S     <no value>     Image files in the selected files will be used.
AUDIO      /S     <no value>     Audio files in the selected files will be used.
PDF        /S     <no value>     Pdf files in the selected files will be used.
LOGREADER  /S     <no value>     Opens the log reader without showing the main
                                 Bulk Meta dialog.

MODE       /K     <string>       Select the mode that’s open by default in the
                                 dialog. Value can be: Append, Clear, Filename, 
                                 FindReplace, Parent, Prefix, or Replace.

                                   e.g: BulkMeta AUDIO MODE="FindReplace" 

                                 This will open the dialog in Find & Replace 
                                 mode with audio files used.

Log Reader:
A Log Reader dialog is available which provides an easy way to view the log file:


The Log Reader has a filter which allows you to type part of a filename to filter the list of log entries shown. The Reset button will clear the filter and display all log entries. Alternatively you can double click an entry in the list to filter based on that entries filename.

You can launch the Log Reader from within the Bulk Meta dialog (There's a new Log File... button in the dialog). Alternatively you can use the BulkMeta command with the LOGREADER argument to just use the log reader alone.

Screenshots:

A few screenshots to demonstrate several modes:

clear replace

4 Likes

@Steve

First of all congratulations on a super script.

I have hit a small visual problem wit the script on my system.

As you can see from the screen shot the box listing the selected files cover where I need to type my changes.

On a more general note, I have to say that bulk editing metadata is a dangerous pastime. I worked for years with large electronic libraries and systems adding metadata to to hundreds of images a day. This little story illustrates the dangers.

A librarian wanted to change the name of the photographer on an image. No problem with the software she was using, but what she did not realise is that she had accidentally also selected another 150 images. The result was a total disaster. There were 150 images with the wrong photographer, and worse still. of course, nobody knew the right one. All she could do was load that latest backup tape and replace the pictures from there.

Almost 25 years of experience in editing metadata has taught me one thing - the watchword is CAUTION

Could I suggest that you include a message box to at least warn the user he is about to edit multiple instances of metadata. It has saved me from metadata mush on many an occasion.

1 Like

I think I've fixed that in 1.0.2 which I have just posted above.

Good idea. Thanks.

There's now a confirmation dialog when you click Ok.

For the braver, there's a configuration option to toggle this if you choose to live without it. Caveat Emptor! :slight_smile:

1 Like

Random idea (that may not make sense for all/large file types): You could make a backup of the old file, then delete it to the recycle bin. That way the original file is available if something goes wrong, but you also don't need to worry about cleaning up all the old backups that accumulate.

1 Like

nice :smiley:

the first if statement in line 68 is always 'true' :wink:
I guess you can cut off a few lines.

maybe in this way:

if (scriptCmdData.func.args.got_arg.audio) {
    dlg.Control("comboCat").value = 1;
    updateList(dlg, srcTab, scriptCmdData);
    updateMetaAudio(dlg);
    updateColsAudio(dlg);
    updateMetadataAudio(dlg, srcTab);
}
else if (scriptCmdData.func.args.got_arg.pdf) {
    dlg.Control("comboCat").value = 2;
    updateList(dlg, srcTab, scriptCmdData);
    updateMetaPdf(dlg);
    updateColsPdf(dlg);
    updateMetadataPdf(dlg, srcTab);
}
else {
    dlg.Control("comboCat").value = 0;
    updateList(dlg, srcTab, scriptCmdData);
    updateMetaImage(dlg);
    updateColsImage(dlg);
    updateMetadataImage(dlg, srcTab);
}
1 Like

Nice one. Thanks. Fixed with 1.0.3.

Thanks for the suggestion. Added to 1.0.4.

2 Likes

The big problem with editing metadata in multiple files, is that it is very possible that the user does not realise the mistake has been made. I know, to my cost, the dangers of discovering the errors weeks after the original editing.

If you can be certain you know you have made a mistake, Leo's solution is very neat. Otherwise, believe you me, you need that warning.

Thats where a good incremental and automatic backup system is important. Something apple has done right with Time Machine.

1 Like

this script getting better and better :smiley:

1 Like

Thats where a good incremental and automatic backup system is important.

oh yeah.... I agree so much :sweat_smile:

1 Like

1.1 posted above with a few new bits added. Including the ability to preview a file in the list, and copy it to a configured location for safety.

3 Likes

Can't help myself. Just updated to 1.1.1.

I've added optional logging so now all changes made to any file is detailed, showing both the old and new metadata. (Should save you from disaster @auden :slight_smile: ) You can also configure the location for the log file.

3 Likes

@ steve
I have watched with admiration some of the clever ideas to get over my fears of errors when you multi-edit metadata fields.

The problem with them all is that they depend of taking actions after the event. What you need to do is to prevent the problems arising in the first place

The recycle bin idea is great providing you know you have made an error very quickly

Incremental back-ups - you would be crazy not to make them, but back-ups that stretch back 10 or 15 years?

The logging idea has the same problem. Short-term it is brilliant, long-term, I fear it would be quite hard to handle.

The best method I have come up with is to make a new folder to contain the files you wish to change. Copy the files you want to change into the folder and run the changes on the files.

Now you have to old files and the changed files. You can make your checks on the changed files and if all is well you can copy them over the originals. A bit of scripting could help automate the move back process

With this in place I will try Steve's clever script.

And what if you make a mistake with the move back process? Human error is impossible to completely eliminate.

I’m reminded of an old saying, paraphrased here : “building something idiot proof is impossible, nature will always provide a better idiot”. :slight_smile:

I am curious why the log file idea is problematic long term - the log appends each operation, no overwrite or delete - it’s a permanent record if you want it to be. Surely it’s a case of searching for a filename to check the history of any changes?

@Steve

That is precisely the problem, we are all idiots from time to time. There is nothing intrinsically wrong with any solution offered here, but I can tell you from bitter experience correcting the metadata on say 100 files is no small undertaking.

The thing I have always loved about Opus is that it gives to tools to make things work in exactly the way that suits you.

My way is to try to make sure I don't make mistakes in this area, and I am glad that this thread has forced me to make some changes to the way I edit metadata. That is not to say that my way is right, but it is the way that suits me.

I think your script is very clever and will be a huge help to many Opus users. Based on my experience, it is simply too risky for me.

But congratulations on the script :grinning:

1 Like

1.2 uploaded above.

Added a Log Reader dialog with filtering options.

2 Likes

Hi Steve Thanks for the script & button, but I have tried that on my FLAC file it's not working.