I have a script which prepends zeros in the file name if the file name is less that 18 digits.
For example if the file name is 1234567, then it should rename it to 000000000001234567 and if it is 123456789, then it makes it 000000000123456789. My code is already doing this functionality
Now my requirement is that if the file name is 1234567-1, then it should make it 000000000001234567_Type_1 and if name is 1234567-a, then it should rename it to 000000000001234567_Type_a.
This means it should keep doing what my script doing but in addition it should suffix _Type_<last character> in the file name. File name can be 1234567 or 123456789 or 1234567-1 or 12345678-b or any thing else but there are always digits and not characters before hyphen (-). There can be multiple files in a folder. Hyphens (-) should be replaced with underscores (_) followed by Type_ and whatever is the last character in the file name.
Here is my existing code:
@echo off
setlocal enableextensions enabledelayedexpansion
rem iterate over tif files:
for %%f in (C:\Task\Drop_Files\*.tif) do (
rem store file name without extension
set FileName=%%~nf
rem Add leading zeroes:
set FileName=00000000000000000!FileName!
set FileName=!FileName:~-18!
set FileName=!FileName!%%~xf
rem Rename the file
rename "%%f" "!FileName!"
)