We received a ton of files from our sponsor and the files are all formatted like this
[ABCD] Title - Id - Description [RS][x264][CHKSUM].txt
I could manually rename one at a time but there are more than 500 files that are sent on a weekly basis.
RS – Reviewer Signature (usually the same person)
CHKSUM – for the file or something.What I need is the following
Title - Id - Description.txt
I need to have the [ABCD] and anything after [RS] removed but before the .txt
I am open to suggestions (powershell, or 3rd party app)
Answer
Here is an example of renaming the files with PowerShell
$files = Get-ChildItem -Path "C:\SponsorFiles" -Filter *.txt
foreach ($file in $files) {
#remove square brackets and spaces
$newName = $file.name -replace ' *(\[.+?\]) *'
#Remove WhatIf if output is as expected
Rename-Item -LiteralPath $file.FullName -NewName $newName -WhatIf
}
Attribution
Source : Link , Question Author : software is fun , Answer Author : jfrmilner