Skip to content

Rename folders #3468

@AlexanderSehr

Description

@AlexanderSehr

Rename plural resource type folder names to singular

Note: Special case config-appsettingsv2

You can use the following script to automate this step:

$mappings = ConvertFrom-Json (Get-Content -Path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\rtMapping.jsonc' -Raw) -AsHashtable

# Anything blow Provider Namespace (must be incremented 1 item at a time as we will otherwise change non-existent folder names after the first level)
foreach ($level in @(8, 9, 10, 11)) {
    $folderPathsInDescLength = (Get-ChildItem -Path '.\modules\' -Directory -Recurse).FullName | Where-Object {
    ($_ -split '\\').Count -eq $level
    } | Where-Object {
        $_ -notmatch '.+\.shared.*|.+\.test.*|.+\.bicep.*'
    } | Sort-Object {
    ($_ -split '\\').Count
    }

    foreach ($folderPath in $folderPathsInDescLength) {

        $folderName = Split-Path $folderPath -Leaf

        if ($mappings.Keys -contains $folderName) {
            $newName = $mappings[$folderName]
            if ($newName -ne $folderName) {
                Rename-Item -Path $folderPath -NewName $newName -Force
            } else {
                Write-Verbose "Skipping $folderName" -Verbose
            }
        } else {
            Write-Warning "No mapping found for $folderName"
        }
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions