Author Topic: New script for renaming views and previews  (Read 4561 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
New script for renaming views and previews
« on: 2017 January 18 13:53:17 »
A new script Utilities > ViewIdReplace should appear as an auto update soon.

Especially during script testing, but also more generally when processing, I often end up renaming the id's of newly created views and previews.

I envision a view id renaming script that accepts a pattern and a replacement string. Multiple instances of this script may be created in the workspace.

Then I drag the appropriate instance onto the view or preview rather than manually renaming.

Here are some examples.

• When I drag a view to create a clone, I want to replace the "_clone" in the name with something else like "_work". This will do it.



So you launch the script, specify a pattern and a replacement, drag an instance onto the workspace, optionally give it a name, and then drag it to the view you want to rename.

• When I create a new preview, I want to replace the "Preview01", or whatever the ending digits are, with something else like "work". This will do it, using a regular expression of the form /pattern/. Here the "." matches any character, and the "*" matches the preceeding pattern 0 or more times. So ".*" matches anything, and the entire id gets replaced with "work":



• When I open two images with the same name, I end up with digits appending one or both, like "integration" and "integration1". Maybe I want to replace the ending digits, if present or not, with something else like "_work". This will do it. "\d*" matches 0 or more digits, and "$" matches the end of the id, so the replacement applies only at the end:



The documentation has a couple more examples, and both the documentation and tooltips show the various pattern options that are available.

Note when the script is open, you cannot drag an instance directly onto a view (error appears), you must drag it onto the workspace, dismiss the script, and then drag the instance. This limitation may be removed in a future release.
Thanks,
Mike
« Last Edit: 2017 October 13 17:41:10 by mschuster »

Offline Andrew J

  • Newcomer
  • Posts: 7
Re: New script for renaming views and previews
« Reply #1 on: 2017 July 20 15:02:26 »
mschuster,

Thank you for developing and sharing this script. I always forget to rename my views to the names used in my PixelMath logic. Now all I have to do is add this script to my process container before the PixelMath scripts and it renames the views to match the names I have in PixelMath. Brilliant!! This is a really handy script.

Andrew J

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: New script for renaming views and previews
« Reply #2 on: 2017 July 20 20:17:08 »
Thank you Andrew.