Question : Batch File - Rename file to todays date . extenstion

Hello Experts,

I want to rename a file to todays date.

This is what I have that doesnt work:

IF EXIST C:\file.bck REN
C:\file.bck [date].bck

Is there a way to do this within a batch file?

Answer : Batch File - Rename file to todays date . extenstion

Here you go!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
REM ****************************************
REM * rename file to YYYYMMDD script
REM * Created 20030617
REM ****************************************
 
REM ****************************************
REM * Set date variables
REM * TODAY = today's date
REM * YEAR = current year
REM * DAY = current day
REM * MONTH = current month
REM ****************************************
 
SET TODAY=%DATE%
SET YEAR=%TODAY:~-4%
SET DAY=%TODAY:~-7,-5%
SET MONTH=%TODAY:~-10,-8%
 
IF EXIST C:\file.bck REN
C:\file.bck %YEAR%%MONTH%%DAY%.bck
Open in New Window Select All
Random Solutions  
 
programming4us programming4us