Solved Batch file for File Copying & renmaing with timestamp

July 3, 2012 at 07:44:37
Specs: Windows 7
Hi there,
I need a batch file, which should create a copy of a file from C:\Document\ABC_07022012.xls folder & rename it to given date in given format.
Source: C:\Document\ABC_07022012.xls (Copy file with to_date or latest date as there will be hundreds of file in one folder with timestamp)
Destination:C:\Document\ABC_07032012.xls (Rename it to future date/tomorrow's date)

See More: Batch file for File Copying & renmaing with timestamp

Report •

July 3, 2012 at 17:28:10
✔ Best Answer
it does use vbscript to do the date-addition.

@echo off & setlocal enabledelayedexpansion
> daa.vbs echo wscript.stdout.write(dateadd("d",1,date))
for /f %%a in ('cscript /nologo daa.vbs') do set nd=%%a
set nd=%nd:-=/%
for /f "tokens=1-3 delims=/" %%a in ("%nd%") do (
set mm=0%%a
set dd=0%%b
set yy=%%c
set nd=%mm:~-2%%dd:~-2%%yy%
set od=%date:/=%
set od=%od:~4%
for %%a in (*%od%.xls) do (
set z=%%~na
set z=!z:~0,-8!%nd%%%~xa
echo copy %%a !z!

ps: might need you to post a copy of your date format:
echo %date%
when my script bombs!

Report •
Related Solutions

Ask Question