Batch Renamer

A GUI for renaming objects en masse. Looks a bit like the Rename dialog.

See also the code snippet by chozo.

When 'Wildcards' is checked, ? matches one character and * matches one or more characters. In the 'prefix', 'suffix' and 'replace with' fields, # represents a number. Use multiple # characters to set minimum number of digits. To insert a string by key from a wavenote, use the syntax {key[,keySepStr[,listSepStr[,matchCase]]]}, where the optional parameters correspond to those used in StringByKey. String parameters do not have to be quoted. DisplayHelpTopic "StringByKey" for details.

Clicking the column title for current names resorts the names alphanumerically, and you can click in the leftmost column and drag to reorder names.

Project Details

Current Project Release

Batch Renamer IGOR.8.00.x-1.95

Release File: Batch Renamer195.zip
Version: IGOR.8.00.x-1.95
Version Date: Sun, 07/04/2021 - 02:07 am
Version Major: 1
Version Patch Level: 95
OS Compatibility: Windows Mac-Intel
Release Notes:

Opens with current data folder visible in wave selector widget

View All Releases

Wow, you have done it already! Excellent job, and with much better code than I could ever write. Here are some features I would find useful:

  • A (don't) match case (for replacement) checkbox
  • A way to reorder the rename list (should template renaming be possible)
  • A template option to give waves consecutive names (e.g., "data###" will give data001, data002 ... etc.)

Really awesome would be to have the option to name waves by some information from the wave's notes, but I have no idea how to implement this. Maybe have a field to give information for a StringByKey search inside the notes?

I also should look more into saving package preferences for my projects...

Thanks, chozo, though I don't believe for a second that the code is any nicer than yours.

This was mostly cobbled together from bits of code I had written for other projects. The tricksy thing is list filtering. The WM wave selector widget has filtering built in, so it's easy to add a setvar to filter the list, but that only fires after you hit enter. If you want the list to respond as you type it gets significantly more complex.

The panel allows you to rename folders and objects within those folders in one action, so reordering the rename list has to be done with care. Maybe I could add column sorting in the listbox. I have code for that - it took me a while to figure out how to do it properly.

I have a feeling that colored text doesn't play nicely with listboxes on Windows, right? Windows uses a really dark blue for selected cells, and changes the text color only for default colored text.

I wonder whether case sensitivity might lead to confusion for users, since Igor is ambivalent about case in object names.

Even if cobbled together, it looks really nice already. Right, case-sensitivity is not so important in Igor, but I thought when replacing parts of names it might be useful to target the letter case to, for example, just replace the second 'd' in "Data_d20" or something. This is how the list-box looks on Win:

The colors are not super pretty (especially with the sub-pixel 'halo' around curved numbers thanks to sub-pixel dithering here on Win10), but everything is readable enough. Also you see that the Prefix and 1 time checkboxes may need a bit of alignment (the prefix controls about 10 units to the left and the time checkbox about 5 units to the right seems good).

Damn, that removes the possibility to complain about missing features in one fell swoop. Excellent work! This is more than most other GUIs are able to provide other than hardcore batch rename utilities. Now the only thing that I have left is to nitpick about the UI. ;) Two things: I noticed that copy-paste always pastes into the filter bar and never into other fields and: The entry fields are quite a bit too tiny to go all out on regEx. :)

I forgot to mention that clicking the column heading for current names resorts the names alphanumerically, and you can click in the first column and drag to reorder. I haven't checked on a pc yet, but I can well imagine that the control layout is ugly. The copy paste bug is fixed.

>  I haven't checked on a pc yet, but I can well imagine that the control layout is ugly.

Yes. This could be taken as but one in the host of examples to demonstrate why Windows needs to fix its UI to copy the elegance in macOS or WaveMetrics needs to use electron to re-code Igor for consistency in UI design on all platforms. :-)

Hi Tony, thank you for the great update! Now the controls look very nice on windows. However, there is still a bug left: The panel keeps inflating when closed and reopened on Windows. Obviously, there is a problem when translating points to pixels (96 dpi on windows), i.e., all panel coordinates get inflated by 1.3333 each time. I get the same problem all the time in the reverse direction (i.e., my tools tend to get too small on Mac). Often a MoveWindow command is the culprit (I really watch out for this command now). Anyway, here is the fix which prevents this:

// resize to restore window size
Variable factor = PanelResolution("BatchRenamerPanel")/ScreenResolution
MoveWindow /W=BatchRenamerPanel prefs.win.left*factor,prefs.win.top*factor,prefs.win.right*factor,prefs.win.bottom*factor

I think there is a mismatch somewhere in the manual. I suspect the notion that the /W=(left,top,right,bottom) in the NewPanel command is in 'points' is just wrong. If I count the pixels I find that this rather sets the size in pixels, which explains the discrepancy to MoveWindow, which set the size really in 'points'. Note that the /W=(left,top,right,bottom) flag for Display seems to be really in points as stated in the manual. Talk about confusing units!

Does this fix it? turns out that MoveWindow isn't needed, ResizeControls takes care of positioning the controls regardless of the coordinates used in NewPanel.

 

Batch Renamer191.zip

In reply to by chozo

>Now the controls look very nice on windows.

by luck rather than design. keeping setvars and checkboxes on separate lines helps.

I've come across the movewindow madness somewhere before, but forgot all about it.

In the end, the only real solution is to test everything on both Windows and Mac. I now tend to test everything on both win/mac and in both Igor 9 and Igor 6.3 if I change something in panels. Quite tedious, but there is often some small detail which is off.

Tony, I am very happy with the Batch Renamer. I would find it convenient, though, if there was a way to switch off printing to the history (besides commenting out the one line with the print command, of course).

Perhaps I should remove the line with print, use execute /P as default and execute /P/Q as a quiet option. I'll add that as a preference in an update, but for now it sounds like you have a solution. I've been finding it quite useful myself - almost enough to justify the time spent fiddling with control positions.

Does anyone need to be able to toggle output to history on the fly, or can this be a set-and-forget option?

Lately, I think tools should have an optional print output, if only for the purpose of documenting what has been done (e.g., logging the analysis process for an archive). My tools are obviously lacking here, but I have it on my list to fix that in the future. I think a checkbox with preferences would be the best option. You already have the preferences stuff nicely in place, so if you can bear to add a checkbox in some corner, this might be most convenient. Or you have a toggle function which could be called once to set the desired behavior (e.g., BatchRenameVerbose(0)). I personally would be more than happy with the latter option.

The history is often the only way to keep track of objects. That's especially true for renamed objects! It would be easy to make a mistake with a batch renaming scheme, perhaps a couple of waves out of order, leading to switched names for data. For that reason I think the default should be to keep a history record of all renaming. My own spectroscopic waves usually have a wavenote that contains metadata describing the data acquisition, together with a trail of other manipulations to the data (baseline correction parameters and so on), which makes it easy for me to identify naming errors. I suspect that you use a similar scheme. Incidentally, I use nested keys in the wavenote, with the outer key using colon and return as key and list separator, and the inner using = and ;

So I might have something like

Optical Parameters:APT=1;VEL=2;TIM=12:02:03;

Baseline Parameters:type=line;coef={1,2};

and so on.

That's a valid point. Indeed, I handle only data which has the original data name in the wave note anyway, so I use renaming usually rather casually. Especially when renaming several waves takes two or more steps I find that the history is quickly "cluttered". But this is really a personal preference. Of course, the safest way is to print every step. It would be great if there would be way to filter the display of the history depending on specific search terms (just like the wave name feature of the data browser). Then one could get a list of specific steps easily, and it would be not problem if there are hundreds of lines of unrelated stuff. Yes, there is the find feature, but I find it somewhat lacking. Anyway, if you rather want to keep printing on in the Batch Renamer all the time, that fine with me as well.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More