Renommer les fichiers d’un dossier par pattern

$folderPath = "C:\dev\test"

$files = Get-ChildItem $folderPath

$removedString = "xxxxxx"
$removedString.Length

Foreach($file in $files) {
    if($file.Name.Contains($removedString)){
        Write-Host $file.Name    
        Get-ChildItem ($folderPath + "\" + $file.Name) | Rename-Item -NewName $file.Name.Substring($removedString.Length, $file.Name.Length - $removedString.Length)
    }
}

Publié par Vincent GUYONVARCH

Je m’appelle Vincent et je suis Cloud Solution Architect Data & AI chez Microsoft. J’aide les entreprises en tant qu’expert sur les technologies Cloud.

Laisser un commentaire