Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, November 3, 2017 10:56 AM
Hello
i notice that robocopy not working with /copy:DA, when I add D flag it always run with T flag. I need to ignore files timestamps and create new ones in destination folder.
Anyone know workarround to this issue ?
All replies (4)
Monday, November 6, 2017 1:26 PM âś…Answered
Thanks for info, but what a shame. Except this issue Robocopy would be a perfect tool. I figured out solution with adding to my batch script, simple PowerShell script which updates CreationTime of copied files.
You have to declare "path" variable which will be used in PS script as a "env" variable (enviroment). After robocopy is succesfuly done script calls "timestamps" PS script which updates time attributes of folders and files in "path" variable with current date.
SET /p s=source ?:
SET /p d=destination?:
SET path_dest=%d%
RoboCopy.exe "%s%" "%d%" *.* /E /B /MT:8 R:99 /XJD /XD %xddir% /ETA /TEE /LOG+:"C:\temp\robo.log"
if %errorlevel% EQU 1 goto timestamp
if %errorlevel% NEQ 1 goto error
:timestamps
start /b powershell -ExecutionPolicy Bypass -file "c:\temp\timestamps.ps1"
Function Set-FileTimeStamps {
Param (
[Parameter(mandatory=$true)]
[string[]]$path,
[datetime]$date = (Get-Date))
Get-ChildItem -ErrorAction silentlyContinue -Recurse -Force -Path $path |
ForEach-Object {
$_.CreationTime = $date
$_.LastAccessTime = $date
$_.LastWriteTime = $date
}
}
[datetime]$date = (Get-Date)
Set-FileTimeStamps -ErrorAction silentlyContinue -path $Env:path_dest -date $date
Saturday, November 4, 2017 10:11 PM
Interesting if you look at the what robocopy runs (in the first section it outputs when run) it does add the T.
Looking at Robocopy - how to discard timestamps others have noticed that and appears to be related to the way robocopy works by comparing timestamps. So as that post what are you trying to achieve overall? Perhaps another way to achieve that.
Monday, November 6, 2017 9:37 AM
Hi Piterooo,
Based on my search, it would appear the undocumented behavior is as follows:
Whenever, the D flag is used for /COPY, robocopy will automatically add the T flag.
However, this does not apply to the directory /DCOPY flag. It can be specified without T and work.
This is by design, and also it is not undocumented.
According to the Robocopy Documentation:
Note: If file Data is copied, then file Timestamps are also copied.
Some people tested it below.
/Copy:D becomes /Copy:DT
/Copy:A becomes /DCopy:DA /Copy:A
/Copy:T becomes /DCopy:D /Copy:T
/Copy:DT becomes /DCopy:D /Copy:DT
/Copy:AT becomes /DCopy:DA /Copy:AT
Hope it will be helpful to you
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Monday, November 6, 2017 1:43 PM
Hi Piterooo,
Glad to hear that you have found a solution and thank you for sharing it here, it will be helpful to other community members who have same questions.
If the reply is helpful, please remember to mark it as answer which can help other community members who have same questions and find the helpful reply quickly.
If any further help needed, please feel free to post back.
Best regards,
Carl
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].