|Okay - the specs I now understand are:|
1. The folder may contain files with names of various lengths.
2. All filenames to be processed will have the .drm extension.
3. Only filenames which are 26 or 27 characters in length are to be processed, all others to remain as-is.
4. Character #18 is to be changed to the final character of the filename.
5. The final 3 characters of the filename are to be removed making the new filenames 23 or 24 characters in length.
6. The original file extension is to be retained.
Test this, please confirm that the script is correct before removing the rem command. Here's hoping for success.
pushd C:\Files\||echo Pushd failed - job terminated.&&exit /b
for /f "tokens=*" %%1 in ('dir /a-d /b *.drm') do (
set file=%%~n1&set extn=%%~x1
for /l %%1 in (0,1,30) do (
if defined chars set /a cnt+=1
if !cnt! gtr 25 if !cnt! lss 28 (
if !cnt! equ 26 (set Second=!file:~18,5!
) else (
if defined First echo %%1 being renamed !first!!last!!second!!extn!&&echo.
rem ren "%%1" "!first!!last!!second!!extn!"
Please come back & tell us if your problem is resolved.