Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I search for this solution as I see there are many different dos renaming threads, but I couldn't find one to do this specifically.
I want to remove 3 characters from a filename very time they occur. The characters are "10M" and they can occur anywhere (except in the first 3 characters of the filename). Some of these filenames are long names too, so I'm not sure if I can do this in dos or not, but this was my first shot.
Thanks.

The batch you find below satisfies your need, but it runs in a DOS box under Windows NT/2K/XP only, it does not work under Win 9X/ME.
It renames the files stored in the directory typed on the command line according to your specifications (excluding those beginning with 10M). Filenames may be long format and contain blank characters. Folder name must not contain blanks.
To run type XStr Folder_Name
or if you want process in the current directory just type XStr . (XStr "dot")To activate erase the Echo in front of thr Ren command at the bottom of code. Do this only when you are sure the script works as you planned.
@Echo Off
Set FDir=%~f1
For /F "tokens=* delims=" %%I in ('Dir %FDir% /B /A:-D') Do Call :SUBST %%I
GoTo :EOF:SUBST
Set FName=%*
Set FHead=%FName:~0,3%
Set FBody=%Fname:~3%
Set FBody=%FBody:10M=%
Set FName=%FHead%%FBody%
If not "%*"=="%FName%" Echo Ren "%FDir%.\%*" "%FName%"
GoTo :EOFI hope this helps, if anything goes wrong post again

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |