I have a series of files that I need to rename on a daily basis. The files I receive have the following format: yyyyMMdd_hhmmss_xxx.someFileName.txt I need to strip out the time stamp in the middle as well as the three digit field preceeding the filename and leave the date and the "someFileName.txt" piece. The resulting filename should look like: yyyyMMddsomeFileName.txt
I'm pretty clueless when it comes to bat files, I've done some experimenting:
@setlocal EnableDelayedExpansion
@for %%i in (.\*.txt) do call rename %%i
:rename
@set dateString=%%i:~0,8%
@set nameString=%%i:~20%
@set combinedString=%dateString%%nameString%
@echo %combinedString%
Clearly, this doesn't actually rename anything yet. It's just supposed to print the combinedString output. I'm getting a syntax error: "The syntax of the command is incorrect ~0,8 ~20"
What's going on here? What's the correct approach for this?