I assume that you know the length of the part before _ and after the underline, as well as the extension. If you do not, it can be more difficult than a simple substring.
cd C:\path\to\the\files for /f %%a IN ('dir /b *.jpg') do ( set p=%a:~0,3% set q=%a:~4,4% set b=%p_%q.jpg ren %a %b )
I just came up with this script and I have not tested it. See this and for more details.
IF you want to assume that you do not know the position of _ , as well as the length and extension, I think you could do something for loops to check the index _ , and then the last index . wrap it in goto and make it work. If you want to get through this problem, I would suggest you use WindowsPowerShell (or Cygwin) at least (for you) or install a more advanced scripting language (think Python / Perl), you will get more support either way.
source share