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
?
def copyFile(fromLocation,toLocation,big=False): print("copy file from " + fromLocation + " to " + toLocation) if big: iFind=fromLocation.rfind('\\') fromLocation1 = fromLocation[: (iFind+1)] fileName=fromLocation[iFind+1 :] toLocation1 = toLocation[:(toLocation.rfind('\\')+1)] strcmd="robocopy "+fromLocation1+" "+toLocation1+" "+fileName print(strcmd) os.system(strcmd) else: shutil.copy2(fromLocation,toLocation)