Move files to a network drive via batch script

  • 8 months ago
Comment

ChatGPT
1 / 1

To move files to a network drive using a batch script, you can use the move command along with the UNC path of the network drive. Here's an example script:

batch
@echo off

set "sourceFolder=C:\SourceFolder"
set "targetFolder=\\servername\sharename\TargetFolder"

move "%sourceFolder%\*" "%targetFolder%\"

echo Files moved to network drive.

Replace C:\SourceFolder with the path to the folder containing the files you want to move, and replace \\servername\sharename\TargetFolder with the UNC path of the target folder on the network drive.

Save the script with a .bat extension and run it. This script will move all files from the source folder to the target folder on the network drive.

Please note that you need appropriate permissions to access the network drive and perform file operations on it. Also, be cautious when moving files, especially if they are important, and make sure to back up your data before running the script.