Heythere.
I need your guys help with file renaming using a .bat file.
I got multiple files that I need to be cropped after specified character number.
For exmample, I want to crop name of the files after their fifth character, this way
filename.exe > filen.exe
anothername.exe > anoth.exe
absolutelydifferentname.exe > absol.exe
And, if possible, I’d like to know how to do the opposite. I mean, leaving the certain # of characters at the end, cropping from the beginning of the filename.
Thank you.
If you want to do it in a batch file, the following should work:
If you wish to change the number of characters used to construct the final filenames, change the “5” in
ren "%%~i" "!filename:~0,5!%%~xi".To take the last 5 characters try:
ren "%%~i" "!filename:~-5!%%~xi"For all except the first 5 characters:
ren "%%~i" "!filename:~5!%%~xi"