"copy /z /w" command not deleting read-only files in destination

May 30, 2008
Given two directories "C:\T" (the source/working directory) and "G:\T" (the destination/backup directory). Executing:

copy /z /w /u /y c:\t g:\t

What happens to read-only files in the destination depends upon if the corresponding file exists in the source director.
  1. If the corresponding file exists in the source directory, the destination file is updated and the read-only attribute is removed.
  2. If the corresponding file does not exist in the source directory, the copy command indicates that the destination file is deleted without actually deleting it nor changing its attributes.
I am using TCC 24.01.41 x64 Windows 10 [Version 10.0.17134.590]
Last edited:
May 30, 2008
/Z isn't supposed to delete files, it's intended to overwrite existing (readonly) files.

I'm going to have to think about whether to allow /Z to delete, or to add another option specifically for that purpose.
Another flag would be fine. I'd just like to point out that the current implementation does output a message that it is deleting the existing read-only files.
May 30, 2008
I found to handle hidden and system files with robocopy requires two passes, the first for normal files (no /IA: option) and the second for the hidden/system files (with a /IA:SH option).
Aug 23, 2010
I'd be surprised if that's actually true.
Try specifying * as attributes list or not specify the list at all.
As last resort, specify all attributes.
May 26, 2008
I found to handle hidden and system files with robocopy requires two passes, the first for normal files (no /IA: option) and the second for the hidden/system files (with a /IA:SH option).
Nah, just don't use that /IA parameter at all. If you want to do make DST look exactly like SRC you can use something as simple as:

robocopy.exe src dst /mir

be careful... /mir will delete files in DST that no longer exist in SRC. If you don't want that, use /e instead.
May 30, 2008
Interesting, I've been using ROBOCOPY since Window XP when I first wrote a batch file to handle all of the common options. The batch file had two work arounds because of issues with ROBOCOPY. 1) The Windows 7 version had a bug that caused a destination directory to be marked as hidden/system if the source was a drive. 2) Check for hidden and/or system files because they were normally ignored. I can finally remove both of these work arounds. I wonder when they corrected this?
May 26, 2008
Item 1 isn't technically a bug. The root directory really does have the HS attributes set. Robocopy dutifully replicates that in the target. I do agree that this is probably always not desired, but you can easily undo it by running attrib after the robocopy command.

I don't know about item 2. As far as I know robocopy has never skipped such files by default, but it's been a long time since I've used the robocopy from XP/2003 days.
Similar threads
Thread starter Title Forum Replies Date
B Can copy command concatenate multiple mp3 files Support 2
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
D How to? Unregister a copy of Take command Support 1
R WAD Copy's command dialogue not working Support 2
T COPY command entry Support 7
M WAD Another weird copy command errror... Support 2
M WAD Copy command fails rather weirdly... Support 2
M “Reawakeng" of an old issue with the "copy" command that I'm not sure I've ever reported in the past Support 6
C Copy (sys) error Support 3
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
vefatica Copy/Paste anomaly Support 4
D Documentation Typo in COPY help Support 0
samintz COPY fails to copy from \\wsl$ Support 20
D Differences between TCC and CMD with COPY /b Support 4
fpefpe copy /u and timestamps Support 4
M Strange error messages from TCC in FTP copy Support 7
G TCMD crash when copy Support 3
Alpengreis How to? Copy DIRs with attributes ... Support 4
E Text copy bug Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
fpefpe copy/cat Support 7
K copy /w slow relative to robocopy /mir Support 0
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
K copy changing destination current directory Support 1
D Keystroke to copy previous argument Support 3
A How to? Copy+Paste in TCMD tabs with Ctrl-Shift-Ins? Support 5
RChrismon How to? Copy TCMD.INI to New Version Support 7
R How to? Append files in multiple subfolders using copy? Support 8
Dick Johnson COPY /u (?) Support 9
fpefpe Documentation copy /u Support 7
R How to? copy /q ABC.txt + DEF.txt is appending hex 1A Support 8
D copy /g only shows transfer rate Support 1
J Error "Contents lost before copy" Support 3
rps Documentation "Copy+Paste+run" question Support 2
fpefpe How to? copy / exclude Support 2
fpefpe robocopy -- copy /w Support 8
C copy /w /p prompts for deletion, but ... Support 3
D Fixed Copy Support 1
fpefpe Documentation copy/move using /c or /u Support 2
samintz WAD Copy/append adds a character Support 3
P Simple RegEx copy Support 9
fromano Fixed COPY ... TO ... crashing Support 3
Alpengreis How to? Copy & Paste without linebreak within TCMD Support 13
D COPY returns ERRORLEVEL 2 Support 5
mdwyer TCC 13 COPY: specified network name is no longer available. Support 5
CWBillow Copy a tree Support 17
J junction copy/move handling Support 6
vefatica Fixed COPY /S ftp://... Support 1
C WAD copy /u ftp local with Timeout? Support 5
vefatica FTP copy interrupted Support 2

Similar threads