private void renameScriptByCopying(ResourceFile script, GhidraScriptProvider provider,
			ResourceFile renameFile) {
		try {
			copyScript(script, renameFile);
		}
		catch (IOException e) {
			Msg.showError(getClass(), getComponent(), "Unable to rename script", e.getMessage());
			return;
		}

		if (!renameFile.exists()) {
			Msg.showWarn(getClass(), getComponent(), "Unable to rename script",
				"The rename operation failed.\nPlease check file permissions.");
			return;
		}

		if (!provider.deleteScript(script)) {
			Msg.showWarn(getClass(), getComponent(), "Unable to rename script",
				"Unable to remove original file.\nPlease check file permissions.");
			renameFile.delete();
			return;
		}
		infoManager.removeMetadata(script);

		if (actionManager.hasScriptAction(script)) {
			KeyStroke ks = actionManager.getKeyBinding(script);
			actionManager.removeAction(script);
			ScriptAction action = actionManager.createAction(renameFile);
			action.setKeyBindingData(new KeyBindingData(ks));
		}

		assert !infoManager.containsMetadata(renameFile) : "renamed script already has metadata";
		infoManager.getScriptInfo(renameFile);

		tableModel.switchScript(script, renameFile);
		setSelectedScript(renameFile);
	}
Copy a script, renaming references to the class name.

@param sourceScript source script
@param destinationScript destination script
@throws IOException if we fail to create temp, write contents, copy, or delete temp
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptComponentProvider.java