Home > Software design >  Swapping folder names from "1 Folder Name" to "Folder Name 1"
Swapping folder names from "1 Folder Name" to "Folder Name 1"

Time:05-16

just checking if there are any ways i.e. cmd prompt to rearrange/swap folder names in batches instead of doing it manually one by one. Our current folders have different folder names i.e "1 Folder Name", "29 Different Folder Name" and we'd like to swap the number to be at the end so it goes "Folder Name 1" instead. I'm talking about around 900 folders, so I appreciate any help. Thank you!

Edit: Every folder has different names so I'm just wanting to swap folder names so the number goes at the end instead of in the front, not rename everything into the same folder name.

CodePudding user response:

You can change folder names like so..in cmd- ren Folder NewFolderName To do what you are wanting to do you will want to write some sort of script. Check out python or you could probably do this with a PowerShell script.

CodePudding user response:

Try this PowerShell script and remove the "-whatif" if it looks good

Foreach ($element in (dir)) {
    $no = $element.filename.split(" ")[0]
    $text = $element.filename.split(" ",2)[1]
    $newFilename = "$no $name"
# Just output text:
    "Ren '$($element.filename)' '$($newFilename)'
    Ren $element.filename $newFilename -whatif
}

It changes every file or filder in the current directory!

  • Related