notes/snippet/shell/rename.ps1

11 lines
404 B
PowerShell

$cwd = Get-Location
Get-ChildItem $cwd | ForEach-Object -Process {
$oldName = $cwd + '\' + $_.name
$newName = $cwd + '\' + $_.name + '.mkv'
# Rename-Item -Path $oldName -NewName $newName
mv $oldName $newName
}
# One line will do
Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace '.txt','.log' }
Get-ChildItem . | Rename-Item -NewName { $_.Name -replace '更多资源-XH1080.com', ''}