copy /w deletes hidden files and excluded files

Suppose there are no hidden files in Dir2. If I do

copy /w Dir1\* Dir2\

then the hidden files in Dir2 will be deleted. Similarly, if there is no file Bar.txt in Dir1 and I do

copy /w /[!Bar.txt] Dir1\ Dir2\

then any file Dir2\Bar.txt will be deleted. Is this WAD? It seems a bit odd.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
| Suppose there are no hidden files in Dir2. If I do
|
| copy /w Dir1\* Dir2\
|
| then the hidden files in Dir2 will be deleted. Similarly, if there
| is no file Bar.txt in Dir1 and I do
|
| copy /w /[!Bar.txt] Dir1\ Dir2\
|
| then any file Dir2\Bar.txt will be deleted. Is this WAD? It seems a
| bit odd.

Deleting of all hidden files from the target that are absent in the source,
hidden ones included, is what I'd expect /w to achieve. As to the second
case, it has incorrect syntax (the file exclusion option is supposed to
precede the /w option), but regardless of order, it seems to me to be a
command too sophisticated for automation as a single action: "make the
target identical to the source, EXCPET ignore any files named bar.txt in
both the source and the target".

BTW, is COPY on your system an alias by any chance?
--
Steve
 
Deleting of all hidden files from the target that are absent in the source,
hidden ones included, is what I'd expect /w to achieve. As to the second
case, it has incorrect syntax (the file exclusion option is supposed to
precede the /w option), but regardless of order, it seems to me to be a
command too sophisticated for automation as a single action: "make the
target identical to the source, EXCPET ignore any files named bar.txt in
both the source and the target".

BTW, is COPY on your system an alias by any chance?

COPY is not an alias on my system. Putting the exclusion in the correct place doesn't change the behavior.

I don't see why you think it is too sophisticated. I'm just saying that I would expect COPY to use the same criteria to select files to operate on in both the source and the target. I find it rather surprising that a command would delete a file that has the hidden, system, and read-only attributes without my specifying an /a: option.
 

rconn

Administrator
Staff member
May 14, 2008
12,369
150
> I don't see why you think it is too sophisticated. I'm just saying that
> I would expect COPY to use the same criteria to select files to operate
> on in both the source and the target. I find it rather surprising that
> a command would delete a file that has the hidden, system, and read-
> only attributes without my specifying an /a: option.

This is WAD. If you want to sync your hidden & system files too, use the
/A:... option.

Rex Conn
JP Software
 
This is WAD. If you want to sync your hidden & system files too, use the
/A:... option.

I'm sorry, but I don't follow. I don't want to sync hidden/system files. In particular I don't want to delete such files in the target directory. Is there a way to do that? copy /a:-h /w still deletes hidden files.

C:\Junk>dir /a

Volume in drive C is OS Serial number is 1ce5:1203
Directory of C:\Junk\*

3/07/2010 12:39p DIR .
3/07/2010 12:39p DIR ..
0 bytes in 0 files and 2 dirs
201,156,771,840 bytes free

C:\Junk>mkdir S

C:\Junk>mkdir T

C:\Junk>T\

C:\Junk\T>touch /c Foo.txt & attrib +h Foo.txt
3/07/2010 12:40:39.945 C:\Junk\T\Foo.txt
___A________I -> _H_A________I C:\Junk\T\Foo.txt

C:\Junk\T>cd ..

C:\Junk>copy /w S\* T\
Deleting C:\Junk\T\Foo.txt
1 file deleted
TCC: (Sys) There are no more files.
"C:\Junk\S\*"
0 files copied

C:\Junk>dir /a T\*

Volume in drive C is OS Serial number is 1ce5:1203
Directory of C:\Junk\T\*

3/07/2010 12:40p DIR .
3/07/2010 12:40p DIR ..
0 bytes in 0 files and 2 dirs
201,156,771,840 bytes free

C:\Junk>T\

C:\Junk\T>touch /c Foo.txt & attrib +h Foo.txt
3/07/2010 12:41:15.749 C:\Junk\T\Foo.txt
___A________I -> _H_A________I C:\Junk\T\Foo.txt

C:\Junk\T>cd ..

C:\Junk>copy /a:-h /w S\* T\
Deleting C:\Junk\T\Foo.txt
1 file deleted
TCC: (Sys) There are no more files.
"C:\Junk\S\*"
0 files copied

C:\Junk>dir /a T\*

Volume in drive C is OS Serial number is 1ce5:1203
Directory of C:\Junk\T\*

3/07/2010 12:41p DIR .
3/07/2010 12:41p DIR ..
0 bytes in 0 files and 2 dirs
201,156,771,840 bytes free
 

rconn

Administrator
Staff member
May 14, 2008
12,369
150
> ---Quote (Originally by rconn)---
> This is WAD. If you want to sync your hidden & system files too, use
> the /A:... option.
> ---End Quote---
> I'm sorry, but I don't follow. I don't want to sync hidden/system
> files. In particular I don't want to delete such files in the target
> directory. Is there a way to do that? copy /a:-h /w still deletes
> hidden files.

/W is a sync; but you apparently don't really want to sync your directories;
you just want to *mostly* sync your directories, but excluding some files.
Unfortunately, there isn't any "mostly sync" option in COPY.

You should probably be using /C or /U instead of /W.

Rex Conn
JP Software
 
/W is a sync; but you apparently don't really want to sync your directories; you just want to *mostly* sync your directories, but excluding some files. Unfortunately, there isn't any "mostly sync" option in COPY.

You should probably be using /C or /U instead of /W.

A "mostly sync" option would be nice, but I can live without it. However, philosophically, I wouldn't expect any command to delete hidden/system/read-only files unless this was clearly documented. I suggest updating the Help for /W.

By the way, I'm actually using "/U /W", but I didn't include the /U in my examples, since it didn't seem relevant.
 
The /U is useless in this context, as /W will override it.

So, /W actually copies all files from the source to the destination, then deletes all files in the destination that aren't in the source. Correct?

I don't think the Help makes that clear. Also, it seems like in some cases there could be quite a bit of needless copying when syncing.

Is there a simple way to do a "copy /e /h /q /Nj /s /u Dir1\ Dir2\", then (or at the same time) delete files in the destination tree that aren't in the source?
 

dim

Dimitry Andric
May 31, 2008
205
1
Netherlands
On 2010-03-07 21:28, David Marcus wrote:

> ---Quote (Originally by rconn)---
> The /U is useless in this context, as /W will override it.
> ---End Quote---
> So, /W actually copies all files from the source to the destination, then deletes all files in the destination that aren't in the source. Correct?

No, the COPY command *itself* copies all files from the source to the destination. :) The /W switch just modifies its behaviour.



> I don't think the Help makes that clear. Also, it seems like in some cases there could be quite a bit of needless copying when syncing.

Quoting the help file:

"/W Delete files in the target directory that don't exist in the source directory."

What is not clear about that?



> Is there a simple way to do a "copy /e /h /q /Nj /s /u Dir1\ Dir2\", then (or at the same time) delete files in the destination tree that aren't in the source?

Yes, use /W, and add the /A: option, as multiple people already told you in this thread. :)
 
Quoting the help file:

"/W Delete files in the target directory that don't exist in the source directory."

What is not clear about that?

That copy ignores /U when you do that. I assume options can be combined unless the Help says otherwise.

Yes, use /W, and add the /A: option, as multiple people already told you in this thread. :)

Maybe you didn't notice the "/u" in what I wrote. In other words, do a one-way sync, but if most files are identical (as judged by the timestamp), skip the extra time needed to copy all the identical ones.
 
Does /W cause copy to first delete everything in the target directory, then do the copy? I.e., is it just a delete followed by a copy? If so, then I understand why you can't combine /W and /U.

Suggested Help text:

/W Delete files in the target directory (including hidden and system, but not read-only files) that don't exist in the source directory. If used with /U, the /U option will be ignored.
 
Hi,

with the latest version of TCMD x32 I have the following effect:

I usually have set the background of my TCC window to blue using OPTION.
While without these settings TCC/LE and TCC x64 come up with a black
background, TCC x32 comes up blue. I don't know where this blue comes
from, I find nothing in the INI files which could be responsible. What
is irritating me is that this blue is of a lighter hue than the blue I
get from the OPTION settings.

Speaking of OPTION: on the first tab of Take Command Options (Window?)
in my german version the next to last entry (Datei automatisch .......)
is cut of by the frame line.

TCMD x64: the installer still shows no license info.

There's another option to set background colors on the second tab
(Tabs?) of the Take Command Options: Fenster (Windows?). But whatever I
set the output colors to, even using admin rights, these setting come up
(Default) after a restart.

Best Regards,

* Klaus Meinhard *
<www.4dos.info>
 
It seems that /U and /W can be combined. And, it seems that the files are deleted before the copying is done, but only the files that need to be deleted are deleted, not the entire directory:

C:\Junk>dir

Volume in drive C is TI105444W0C Serial number is 709c:de9d
Directory of C:\Junk\*

3/11/2010 12:34p DIR .
3/11/2010 12:34p DIR ..
0 bytes in 0 files and 2 dirs
271,641,681,920 bytes free

C:\Junk>ver /r

TCC 11.00.43 x64 Windows 7 [Version 6.1.7600]
TCC Build 43 Windows 7 Build 7600
Registered to davidmarcus - 1 System License

C:\Junk>mkdir S

C:\Junk>mkdir T

C:\Junk>touch /c S\Foo.txt
3/11/2010 12:35:21.844 C:\Junk\S\Foo.txt

C:\Junk>copy /s /w S\ T\
C:\Junk\S\Foo.txt => C:\Junk\T\Foo.txt
1 file copied

C:\Junk>copy /s /w S\ T\
C:\Junk\S\Foo.txt => C:\Junk\T\Foo.txt
1 file copied

C:\Junk>copy /s /u /w S\ T\
0 files copied

C:\Junk>touch /c T\A.txt
3/11/2010 12:37:47.923 C:\Junk\T\A.txt

C:\Junk>touch /c T\Z.txt
3/11/2010 12:37:59.810 C:\Junk\T\Z.txt

C:\Junk>copy /s /w S\ T\
Deleting C:\Junk\T\A.txt
Deleting C:\Junk\T\Z.txt
2 files deleted
C:\Junk\S\Foo.txt => C:\Junk\T\Foo.txt
1 file copied
 
Similar threads
Thread starter Title Forum Replies Date
K iftp script copy deletes target files Support 17
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 /z /w" command not deleting read-only files in destination Support 10
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
B Can copy command concatenate multiple mp3 files Support 2
rps Documentation "Copy+Paste+run" question Support 2
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
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
D How to? Unregister a copy of Take command Support 1
vefatica FTP copy interrupted Support 2
C How to? COPY ftp folder query Support 7
R How to? TCC 16.03: copy a file to the clipboard? Support 10
jadaml Documentation Is COPY realy doesn't work for any HTTP and FTP? Support 3

Similar threads