RenameWorkspaces v1

../_images/RenameWorkspaces-v1_dlg.png

RenameWorkspaces dialog.

Summary

Rename the Workspace. Please provide either a comma-separated list of new workspace names in WorkspaceNames or Prefix and/or Suffix to add to existing names

Properties

Name Direction Type Default Description
InputWorkspaces Input str list Mandatory Names of the Input Workspaces
WorkspaceNames Input str list   New Names of the Workspaces
Prefix Input string   Prefix to add to input workspace names
Suffix Input string   Suffix to add to input workspace names

Description

Renames a list of workspaces in the data service. This renaming is done by either replacing with new names in a list or adding a prefix, suffix or both prefix and suffix. The Renaming is implemented by calling RenameWorkspace as a child algorithm having defined the output workspace appropriately.

If run on a group workspace, the members of the group will be renamed in the same manner as done by RenameWorkspace.

The new names can be either explicitly defined by a comma separated list or by adding a prefix, suffix or both a prefix and suffix.

Warning

No new name can be the same as any existing workspace, even if that existing workspace is also being renamed. Duplicate names may cause the loss of a workspace.

Usage

Example - New names:

# Make sure there is nothing in the ADS before we begin
mtd.clear()

names = ['ws1', 'ws2', 'ws3']

# Create some dummy workspaces
for name in names:
  CreateWorkspace([0], [0], OutputWorkspace=name)

print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames()

RenameWorkspaces(names, WorkspaceNames=['new_ws1', 'new_ws2', 'new_ws3'])

print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames()

Output:

Workspaces in the ADS _before_ renaming: ['ws1', 'ws2', 'ws3']
Workspaces in the ADS _after_ renaming: ['new_ws1', 'new_ws2', 'new_ws3']

Example - Using prefix and suffix:

# Make sure there is nothing in the ADS before we begin
mtd.clear()

names = ['ws1', 'ws2', 'ws3']

# Create some dummy workspaces
for name in names:
  CreateWorkspace([0], [0], OutputWorkspace=name)

print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames()

RenameWorkspaces(names, Prefix='new_', Suffix='_name')

print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames()

Output:

Workspaces in the ADS _before_ renaming: ['ws1', 'ws2', 'ws3']
Workspaces in the ADS _after_ renaming: ['new_ws1_name', 'new_ws2_name', 'new_ws3_name']

Categories: Algorithms | Utility | Workspaces