Link to home
Start Free TrialLog in
Avatar of red_white
red_white

asked on

Help to copy file and rename source file

Hi All

I have to copy file from c:\ to d:\ and after copy rename source file (or stamp with current date)
OS: Windows XP/Vista/Windows 7/Windows 2003

Thanks
SOLUTION
Avatar of AnilKumarSharma
AnilKumarSharma
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of red_white
red_white

ASKER

Thanks

How can I add curent datum to source file after copy file to destination folder.
hola este script te permite pasar como parametro una fecha de esta manera puedes renombrar los ficheros de origen.
try it

http://www.robvanderwoude.com/datetimentexamples.php

saludos


 

hi this script as a parameter lets you pass a date in this way you can rename the source files.

try it
Check following batch script if this works for you!

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=*" %%I IN ('DIR C:\DATA\*.* /B') DO (
	SET MM=%DATE:~4,2%
	SET DD=%DATE:~7,2%
	SET YYYY=%DATE:~10,4%
	ECHO Coping %%I
	COPY "%%I" "D:\DATA\%%~nI_!MM!_!DD!_!YYYY!%%~xI">NUL)

Open in new window

I found way to rename file with current date
ren *.log %date:~-10,2%%date:~-7,2%%date:~-2,2%.log
but will be better to add date to source file.

Regards to all
Hi Farhankazi

This batch scrip add date to  name.file  on destination. I need script after copy file from  c:\ to d:\ to add date to file on c:\

regards
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Farhankazi

Thanks, that was what I need.
Any site to learn more about batch script?

Regards