Copy files with Timestamp

May 3, 2006 at 14:17:58
Specs: WinXP, Intel 2 gig
I have some files I need to copy off a server but want to retain the creation date.

copy somefile.txt somefile%date:~10,4%%date:~7,2%%date:~4,2%.txt Will put todays date on the filename.

IS there a way to append the file date in the name on a copy or rename?

See More: Copy files with Timestamp

Report •

May 3, 2006 at 15:36:39

Maybe wording similar to this.
copy file off server with timestamp

Report •

May 3, 2006 at 16:58:43
Check out this thread. If your file system is FAT32 xcopy will work. If not, well .....


Report •

May 3, 2006 at 17:28:29
Try this:

::== keepdat7.bat
:: stamp file with date before copy to keep orig date
:: file date layout is 04-05-06 05:52

@echo off
for /f "tokens=*" %%F in ('dir /b/a-d') do call :sub1 %%F
goto :eof


set stamp=%~t1
set stamp=%stamp:~0,11%%stamp:~12,2%
echo copy %1 %~n1 %stamp%%~x1%
goto :eof

You may want to tinker with it and get the spaces out of the filenames. I certainly would. I don't need no steenking spaces.

If at first you don't succeed, you're about average.


Report •

Related Solutions

May 3, 2006 at 19:54:26
I guess I should have clarified. I am wanting to append the file date to the file name on copy or rename or move..

I found this in the batch parameters help.

%~t1 Expands %1 to date and time of file.

I just don't know how to use it with the xcopy command.


Report •

May 4, 2006 at 06:14:08
Thanks Mechanix2Go
That was exactly what I was looking for

Report •

Ask Question