ChrisCalvert
Technical User
I see a few subjects in here about adding a date to a file name, but I need to see if anyone can help me with a little modification to this. I need to locate a file named SMFyymmdd and rename it. The yy is 2digit year and mmdd is the two digit month and day. The code below is what I was looking to modify, but if someone has entirely new code, that is fine too. I just need to rename these files (adding a .txt extension). All I really need it a way to strip off the first two digits of the date, or some way not to ever get them at all.
Thanks in advance for any help.
-----------------------------------------------
date /t returns "Wed 06/04/2003"
time /t returns "15:29"
for /f "tokens=2 delims= " %%a in ('date /t') do set temp=%%a
This strips off "Wed" leaving you with "06/04/2003"
for /f "tokens=1-3 delims=/" %%a in ("%temp%"
do (set month=%%a& set day=%%b& set year=%%c)
*****I know I need to change this somehow, as I only
want the 03 and not the 2003***********
Now we have 06 & 04 & 2003 in the environment
for /f "tokens=1-2 delims=:" %%a in ('time /t') do (set hour=%%a& set min=%%b)
and time is split into 15 & 29
ren test.txt %month%-%day%-%year%.txt
****and here, I suppose I just reverse this command.*****
Thanks in advance for any help.
-----------------------------------------------
date /t returns "Wed 06/04/2003"
time /t returns "15:29"
for /f "tokens=2 delims= " %%a in ('date /t') do set temp=%%a
This strips off "Wed" leaving you with "06/04/2003"
for /f "tokens=1-3 delims=/" %%a in ("%temp%"

*****I know I need to change this somehow, as I only
want the 03 and not the 2003***********
Now we have 06 & 04 & 2003 in the environment
for /f "tokens=1-2 delims=:" %%a in ('time /t') do (set hour=%%a& set min=%%b)
and time is split into 15 & 29
ren test.txt %month%-%day%-%year%.txt
****and here, I suppose I just reverse this command.*****