Hide XCOPY confirmation of number of files copied
Asked Answered
Z

5

28

I've had a look at the switches for XCOPY and can't seem to find one that suppresses the confirmation of the number of files that have been copied.

Do you know if this is possible?

Thanks in advance,

Dave

Zoller answered 29/7, 2013 at 12:25 Comment(0)
H
37

you can simply send it to nul:

xcopy source destination options > nul
Halftruth answered 29/7, 2013 at 12:28 Comment(3)
As easy as that. Thanks!Zoller
But what if I want the names of the files copied to be displayed (e.g. xcopy /f) but not the final "files copied" message?Lole
Figured it out, see my answer.Lole
L
20

If you want to see messages about which files are being copied but suppress the final message about how many files were copied, then you can use find:

xcopy source destination options|find /v "File(s) copied"

This will display all lines of output that don't contain the string "File(s) copied". Use the /F option to xcopy to display full source and destination filenames.

Lole answered 22/11, 2013 at 17:57 Comment(2)
Confirmed: this solution worked exactly as I needed. I had a perpetually running CMD file that I wanted to copy files in a source directory tree whenever a source file was updated. I was using > nul before to suppress too much output, but I wanted to change it to list the filenames whenever a copy occurred. Changing it to use FIND /V "File(s) copied" was perfect.Hypertension
This only works if the system language is set to English. I can be adapted for your language settings, or for a more generic solution something like this could be used: xcopy src dst opt |findstr "\\", but make sure you have a backslash in the source directory (e.g. use .\src if you're copying from a local directory).Piegari
L
1

xcopy doesn't handle non-standard characters (e.g., «׃¿) ... use xxcopy instead: xxcopy "G:\Files\" /L /S /ZS

/ZS suppresses all the summary reporting and leaves only the filenames.

Landsknecht answered 28/8, 2016 at 1:33 Comment(0)
I
1

You can try this:

xcopy "C:\source_folder\test_file.txt" "C:\destination_folder" /Q > nul

/Q removes the file name while copying and >nul removes the prompt ".. File(s) copied"

Intervale answered 30/8, 2018 at 8:54 Comment(0)
G
0

Just use >nul 2>&1 will supress all the output of the the line.
For example echo Hello World >nul 2>&1 will have no output.

Guevara answered 4/9, 2018 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.