Score:-1

Windows Server 2019 - renaming files with some naming convention

lb flag

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)

br flag
split on the `][` chars and take the part that you want from that list.
Score:0
ar flag

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
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.