Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query
It seems like you are trying to rename a file using a timestamp as part of the file name. The code you posted will work on Windows Server 2022 Datacenter 64-bit Version 21H2(Build 20348.1487), but it might not produce the desired result in terms of the format of the timestamp.
Here's an updated version of the code that produces a timestamp in the format of "MMDDYYYY_HHMM" (e.g., "02072022_1648"):
@echo off
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
set Timestamp=%mydate:~-2%%mydate:~-7,2%%mydate:~-10,4%_%mytime%
ren "%dataexportfilename%.CSV" "%dataexportfilename%_%Timestamp%.CSV"
If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.