User Tools

Site Tools


script:powershell:rename

Renommer plusieurs fichiers

#Remove 1080P in the item object name
Get-ChildItem -Filter '*1080P*' -File | Rename-Item -NewName {$_.Name -replace '1080P',''}

Set-Location 'C:\users\t9258633\Application Data' # selectionner le dossier racine sur lequel on va travailler
                #Text corrector for Executable path
                $hash = @{}
                $hash.'.' = ' '
                $hash.'_' = ' '
                $hash.'-' = '_'
                $hash.'1080P' = ''
                $hash.'720P' = ''
                $hast.'1080' = ''
                $hash.'720' = ''
                $hash.'AC3' = ''
                $hash.'ACC' = ''
                $hash.'   ' = ' '
                $hash.'  ' = ' '

Get-ChildItem -include ('*.MKV','*.MP4') -Recurse -file | ForEach-Object {
$extension = $_.Extension
$basename = $_.BaseName
                Foreach ($key in $hash.Keys)
                {
                    $basename = $basename.Replace($key, $hash.$key)
                }
                [string]$newName = $basename,$extension
                Rename-Item -Path $_.FullName -NewName $newName
}

script/powershell/rename.txt · Last modified: 2020/08/10 23:07 (external edit)