Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $originalFilesDirectory = "C:\your\directory\here"
- $files = Get-ChildItem -Path $originalFilesDirectory | Where-Object { $_.Name -notmatch "Renamed" }
- $renamedFilesDirectory = $originalFilesDirectory + "\Renamed"
- if (!(Test-Path $renamedFilesDirectory)) { New-Item -Path $renamedFilesDirectory -ItemType Directory }
- foreach ($file in $files) {
- Write-Host "You are about to rename $file"
- $newName = Read-Host "What would you like to rename this file to?"
- try {
- Copy-Item -Path $file.FullName -Destination "$renamedFilesDirectory\$newName$($file.Extension)" -ErrorAction Stop
- Rename-Item -Path $file.FullName -NewName "$($file.Name).Renamed"
- Write-Host "Rename Successful" -ForegroundColor Green
- }
- catch { Write-Host "Rename Failed: $($_.Exception.Message)" -ForegroundColor Red }
- Write-Host
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement