robocopy transfer file and not folder

116

I'm trying to use robocopy to transfer a single file from one location to another but robocopy seems to think I'm always specifying a folder. Here is an example:

robocopy "c:\transfer_this.txt" "z:\transferred.txt"

But I get this error instead:

2009/08/11 15:21:57 ERROR 123 (0x0000007B) Accessing Source Directory c:\transfer_this.txt\

(note the \ at the end of transfer_this.txt)

But if I treat it like an entire folder:

robocopy "c:\folder" "z:\folder"

It works but then I have to transfer everything in the folder.

How can I only transfer a single file with robocopy?

file-transfer
robocopy
asked on Server Fault Aug 11, 2009 by (unknown user) • edited Nov 9, 2017 by Kevin Panko

4 Answers

151

See: Robocopy /?

Usage : ROBOCOPY source destination [file [file]...] [options]

robocopy c:\folder d:\folder transfer_this.txt
answered on Server Fault Aug 11, 2009 by KPWINC • edited Mar 2, 2016 by Desperatuss0ccus
20

According to the Wikipedia article on Robocopy:

Folder copier, not file copier

Robocopy syntax is markedly different from standard copy commands, as it accepts only folder names as its source and destination arguments. File names and wild-card characters (such as *.*) are not valid source or destination arguments. Files may be selected or excluded using the optional filespec filtering argument. Filespecs can only refer to the filenames relative to the folders already selected for copying. Fully-qualified path names are not supported.

For example, in order to copy the file foo.txt from directory c:\bar to c:\baz, one could use the following syntax:

robocopy c:\bar c:\baz foo.txt

answered on Server Fault Aug 30, 2010 by Adrian De Leon • edited Nov 9, 2017 by Kevin Panko
2

Try inserting a space before the destination, like this:

robocopy "c:\transfer_this.txt" "z: \this.txt" 

notice the space after the destination "folder" z:.

answered on Server Fault Jun 29, 2015 by user296831 • edited Jun 29, 2015 by HBruijn
-4

robocopy Q:\ F:\Dopbox "Microsoft Office.zip" /MT:128

answered on Server Fault Jun 4, 2016 by Dale

User contributions licensed under CC BY-SA 3.0