If there is always an _ after the first x characters, then the following will work from the command line (no batch needed)
for /d %A in (*) do @for /f "delims=_ eol=_" %B in ("%A") do ren "%A" "%B"
Double the percents if you put the above command within a batch script.
If you cannot rely on _ after the first x characters, then this command should work from the command line, preserving the fist 8 characters:
for /d %A in (*) do @set "folder=%A"&call ren "%^folder%" "%^folder:~0,8%"
Or you could use this batch scrip to preserve the first 8 characters:
@echo off
setlocal disableDelayedExpansion
for /d %%A in (*) do (
set "folder=%%A"
setlocal enableDelayedExpansion
ren "!folder!" "!folder:~0,8!"
endlocal
)
Or you could use my JREN.BAT regular expression renaming utility. It is pure script (hybrid batch/JScript) that runs natively on any Windows machine from XP onward - no 3rd party exe file required.
Remove everything from the first _ onward
jren "_.*" "" /d
Preserve the first 8 characters
jren "^(.{8}).*" "$1" /d
Note:
If you were trying to rename files instead of folders, then you could do something like
ren *.txt ????????.txt
But unfortunately, you cannot use wildcards when renaming folders. So this technique is useless for folders. See How does the Windows RENAME command interpret wildcards? for more info.