Skip to content

Instantly share code, notes, and snippets.

@t3knoid
Last active October 4, 2018 19:26
Show Gist options
  • Save t3knoid/506ca498828f604592cdd89072922076 to your computer and use it in GitHub Desktop.
Save t3knoid/506ca498828f604592cdd89072922076 to your computer and use it in GitHub Desktop.
One-liner to batch rename same named folders or files
The following DOS batch one liner will rename many same-named folder folders.
The following example will rename folders under "Reports Test 2\data" that ends with "Custodian1" and renames it to "Custodian2."
for /f "tokens=*" %a in ('dir /b /s "Reports Test 2\data" ^| findstr /r "Custodian1$"') do ren "%a" "Custodian2"
This can be easily customized for example to rename folders or files in the current folder:
for /f "tokens=*" %a in ('dir /b') do ren "%~na" "%~na2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment