Computing.Net > Forums > Windows XP > Copy files with Timestamp

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Copy files with Timestamp

Reply to Message Icon

Name: jk26
Date: May 3, 2006 at 14:17:58 Pacific
OS: WinXP
CPU/Ram: Intel 2 gig
Product: Compag
Comment:

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?




Response Number 1
Name: Johnw
Date: May 3, 2006 at 15:36:39 Pacific
+1
Reply:


Maybe wording similar to this.
copy file off server with timestamp
http://www.google.com.au/search?hl=en&q=copy+file+off+server+with+timestamp&btnG=Search&meta=



Response Number 2
Name: XpUser
Date: May 3, 2006 at 16:58:43 Pacific
+1
Reply:

Check out this thread. If your file system is FAT32 xcopy will work. If not, well .....

i_XpUser



Response Number 3
Name: Mechanix2Go
Date: May 3, 2006 at 17:28:29 Pacific
+1
Reply:

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

:sub1

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

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.

M2



Response Number 4
Name: jk26
Date: May 3, 2006 at 19:54:26 Pacific
+1
Reply:

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.


Thanks



Response Number 5
Name: jk26
Date: May 4, 2006 at 06:14:08 Pacific
+1
Reply:

Thanks Mechanix2Go
That was exactly what I was looking for



Related Posts

See More



Reply to Message Icon

Win XP only boots in Safe... hard drive not recognized



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Google Ads



Results for: Copy files with Timestamp

Losing file attributes while copy! www.computing.net/answers/windows-xp/losing-file-attributes-while-copy/163478.html

copy file with batch www.computing.net/answers/windows-xp/copy-file-with-batch/182377.html

Copy files with original date/time www.computing.net/answers/windows-xp/copy-files-with-original-datetime/144717.html