Solved

how to retain directory timestamp when copying between drives

Posted on 2011-03-09
4
2,837 Views
Last Modified: 2012-05-11
Hi
I am trying to make a copy of the files/folders on one drive to a folder in another drive (backup). I am wanting to keep everything as is is in the source, so attributes/timestamp etc for files and folders.
I have tried copy, xcopy and robocopy. I can get xcopy and robocopy to retails the file attributes/timestamp, but the folders in the destination end up with the current days timestamp, not its original. I am using the /DCOPY:T in Robocopy, but reading around it seems the drive to drive copy is causing the issue. Is there any (free/easy) way to regularly copy drive (just modified items) to a folder on another drive.
I am using Win7 Pro x64, NTFS on all drives, robocopy version XP027.
cheers
0
Comment
  • 2
4 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 35090734
This is a fun one. Xxcopy wil do it but it's not free. I think Syncback keeps folder timestamps.
0
 
LVL 6

Expert Comment

by:mrcannon
ID: 35090744
I believe robocopy with the /COPYALL or the /copy:T  switch is what you need.



http://ss64.com/nt/robocopy.html
0
 
LVL 11

Accepted Solution

by:
Plantwiz earned 250 total points
ID: 35090753
You may want to review this thread:
http://www.technologyquestions.com/technology/windows-xp/191876-robocopy-command-directory-time-stamp-copy.html

It appears that robocopy will not preserve the date stamp
of a folder. However, you do the following:
1. Use robocopy to copy a folder, complete with subfolders.
2. Compile a list of all folder dates.
3. Use a "touch" utility to apply the folder dates to the target folder.

The batch file below will do just that. It makes use of
DirDate.exe, which you can download from
http://www.datamystic.com/buy/dirdate.html.
DirDate is not free but you might find other touch tools that are.

The batch file relies on drive T: not being used for anything
else. You must remove all # characters - they only serve to
mark the beginning of each line. Do not retype the file - use
copy & paste instead.

#@echo off
#set first=true
#set DDate=zzz
#set Source=d:\temp
#set Target=d:\New
#set TempFile=d:\dir.tmp
#set TouchTool=C:\Program Files\DataMystic\DirDate\dirDate.exe
#if exist d:\Touch.bat del d:\Touch.bat
#
#robocopy "%Source%" "%Target%" *.* /s
#
#subst T: "%Source%"
#dir T:\ /s /ad /tw | findstr "Directory .." > "%TempFile%"
#for /F "delims=" %%a in ('type "%TempFile%"') do call :Sub %%a
#subst T: /d
#
#subst T: "%Target%"
#call d:\Touch.bat
#subst T: /d
#
#goto :eof
#
#=============================
#:Sub
#set parms=%*
#if %parms:~0,3%==Dir set Dir=%parms:~13%
#if not %parms:~0,3%==Dir set DDate=%parms:~0,10%
#if not %DDate%==zzz (
# if not %first%==true echo "%TouchTool%" Date=%DDate% "%Dir%" >>
d:\Touch.bat
# set first=false
# set DDate=zzz
#)




And if you are inclined to use a different tool:
http://lifeonubuntu.com/keep-existing-file-attributes-during-copy/
0
 
LVL 6

Expert Comment

by:mrcannon
ID: 35090772
Sorry AotearoaPeoplesNetwork I just realized I did not read your question fully and you were already at Robocopy.  Plantwiz's find looks promising though.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now