Solved

how to retain directory timestamp when copying between drives

Posted on 2011-03-09
4
2,970 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 39

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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