Change multiple entries in RDM

Change multiple entries in RDM

avatar

We want to add the matchcode of the company to all entries below a folder.

For example we have the folder: DEV - Devoltuions SA

We want to add the matchcode (DEV) to all entries which are in this folder.

Like: DEV - Server5 / DEV - Firewall and so on.

Is there a function in RDM which can do this?

Second question: are there any placeholders we can use, to create new entries, so it always takes the name or the matchcode which is defined in the folder above.

Thanks
Martin

All Comments (11)

avatar

Hello,

Thank you for reaching out to us regarding this,

Could you please specify the version of RDM you are currently using?
What type of data source are you using?

To clarify, you would like to add the (DEV) value to the names of all entries inside this folder without removing the original names?

Perhaps you could use the variable $PARENT_CUSTOM_FIELD1$, which will return the value present in the Custom field of the parent entry that would in this case be the folder,

Let me know,

Best regards,

Samuel Dery

avatar

Hello,

We are using V 2025.3.21.0 an we are using devolutions server on prem.

Yes, you are right. To clarify, you would like to add the (DEV) value to the names of all entries inside this folder without removing the original names?
We want to add the (DEV) to all entries under the initial folder with the name of our clients

best rgards,
Martin

avatar

Hello,

Thank you for your reply,

I would recommend you test this on a duplicate or test entry first to ensure the it provides the desired results, however from testing on my end the following command should achieve this.

You can select the entries and go under "Edit" -> "Edit (Special Actions)" -> "Custom PowerShell Command" and use the following command:

$prefix = '(DEV) '
if (-not $connection.Name.StartsWith($prefix)) {
    $connection.Name = $prefix + $connection.Name
    $null = $RDM.Save()
}

Let me know if this works as expected for you

Best regards,

Samuel Dery

avatar

Hey Sam

Thanks for the script. Just to add, the Letters in the (%TEXT%) will always be different. Every folder has a different Matchcode. So the prefix should take the letters within the brackets from the folder.

Best regards
Patrick

avatar

Hello,

Thank you for your reply,

I see, did the script work as expected for you, or have you made the changes required for it to work?

Let me know if you need further assistance with this,

Best regards,

Samuel Dery

avatar

Hi Sam

I was hoping you could adjust the script so it would take the letters before the "-" here:

Folder name : DEV - Devoltuions SA

So it should add DEV in front of all entries. How could this be done?

Thanks and best regards.
Patrick

avatar

Hello,

Thank you for your reply,

The following should work:

$prefix = 'DEV - '
if (-not $connection.Name.StartsWith($prefix)) {
    $connection.Name = $prefix + $connection.Name
    $null = $RDM.Save()
}

As mentioned previously, I would recommend you test this on a duplicate or test entry first to ensure it provides the desired results,

Let me know if this helps,

Best regards,

Samuel Dery

avatar

Hi Samuel

Thanks a lot. Like that it uses always "DEV -" to put in front.
But the script should search for the term (in this example it is DEV but it's something else in every folder) before the hyphen and put this before all the entries below.

Could you adjust the script to search for the term instead of a fixed one?

Thanks and best regards.
Patrick

avatar

Hello Patrick,

Thank you for your reply,

I'm not sure I understand. You can modify the 'DEV - ' value in the script to what you need for each folder.

$prefix = 'Change Me - '
if (-not $connection.Name.StartsWith($prefix)) {
    $connection.Name = $prefix + $connection.Name
    $null = $RDM.Save()
}


Let me know if this helps,

Best regards,

Samuel Dery

avatar

Hi Samuel

I need to add different prefixes of about 100 folders to the entries beneath them.
So I don't want to change it 100 times.

So instead of the change-me text I need something that looks for the text before the hyphen of the folder and adds this prefix to all 50 entries in this folder.

And do this 99 times more for all other folders which all have different names before the hyphen.

Hope this clears it up.

Best regards
Patrick

avatar

Hello,

Thank you for your reply,

You can try the following:

# Build prefix from the immediate parent folder: take text before the first dash and keep that dash
$groupPath = $connection.Group
if ([string]::IsNullOrWhiteSpace($groupPath)) { return }

$parentFolder = ($groupPath -split '[\\/]')[-1].Trim()
if ([string]::IsNullOrWhiteSpace($parentFolder)) { return }

# Capture: tag (before dash) + the dash character itself (-, – or —)
$match = [regex]::Match($parentFolder, '^\s*(?<tag>.+?)\s*(?<dash>[-–—])')
if (-not $match.Success) { return }

$tag  = $match.Groups['tag'].Value.Trim()
$dash = $match.Groups['dash'].Value
if ([string]::IsNullOrWhiteSpace($tag)) { return }

# Prefix keeps the dash from the folder, with normalized spacing "TAG {dash} "
$prefix = "$tag $dash "

# --- Avoid re-adding if it's already there ---

# 1) Exact prefix (case-insensitive) already at the start?
if ($connection.Name.StartsWith($prefix, [System.StringComparison]::OrdinalIgnoreCase)) { return }

# 2) Common variants like "(TAG) - " or "[TAG] - " already at the start?
$escapedTag = [regex]::Escape($tag)
$alreadyPattern = "^(?:\(|\[)?$escapedTag(?:\)|\])\s*[-–—]\s+"
if ($connection.Name -match $alreadyPattern) { return }

# Add the prefix once
$connection.Name = $prefix + $connection.Name
$null = $RDM.Save()

My recommendation would be to test this on a few test folders first to ensure the desired results and create a backup before using it on the full data source.

Let me know if this helps,

Best regards,

Samuel Dery