1.

Solve : copy file from loca disk to network drive and rename the file to filename + date?

Answer»

hi! There i am new to writing batch file scripts. I have found some information on copying a directory from local directory to a network drive , the directory will be the system date. BU t i am looking to backup a single file to a network directory and at the end of file NAME the date should be added without changing the file extension.

For example i have a file in my C:\Test\testing.mdb

i want it to copy to my network shared drive s:\backup\testing_06_19_2007.mdb

i have added the CODE i used renames the directory but not the file. Anyone could help me to solve.

below is my code

@echo off
:: variables
set drive=S:\Backup
set HOUR=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up directory...
%backupcmd% "C:\Test" "%drive%\%folder%"

echo Backup Complete!
@pause

Thanks in advance....



Discussion

No Comment Found