I need to rename multiple files in a loop and include a time stamp… My struggles begin with updating the timestamp for each file so the file has a unique name.
setlocal enabledelayedexpansion
SET date=%date:~-4,4%%date:~-10,2%%date:~-7,2%
for /f %%a in ('dir /b TCA_*') do (SET
time=%time:~-11,2%%time:~-8,2%%time:~-5,2%%time:~-2,2%
ren %%a %date%TCA_%time%.txt)
Thanks
While in a loop, variables don’t update. To circumnavigate this, the
setlocal enabledelayedexpansionscript was added.Basically, if you want them to update, you need to encase them in exclamation marks (!) instead of percent signs (%).