- 1 year ago
Batch to copy file from local pc to server
Comment
1 / 1
To copy a file from a local PC to a server using a batch script, you can use the robocopy
command or the xcopy
command. Below are examples for both methods:
Using Robocopy:
batch@echo off
set "sourceFile=C:\path\to\local\file.txt"
set "destinationServer=\\server\share\folder"
robocopy "%sourceFile%" "%destinationServer%" "file.txt"
Using Xcopy:
batch@echo off
set "sourceFile=C:\path\to\local\file.txt"
set "destinationServer=\\server\share\folder"
xcopy "%sourceFile%" "%destinationServer%\file.txt"
Replace C:\path\to\local\file.txt
with the full path of the file you want to copy from your local PC, and \\server\share\folder
with the network path of the folder on the server where you want to copy the file to.
Save the batch script with a .bat
extension, and then run it by double-clicking on the batch file. The file will be copied from your local PC to the specified server location.