Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch script to move files

I need to move files from one directory to another in windows, and I need to write this in a batch script.

We have written a SQL job where backup files will be created every 4 hours on the D: drive and last 4 backup files will be saved and others will be deleted.

I need to write a batch script to move these files from the D: drive to the E: drive every 10 hours.

Can anyone help me to write this script.

like image 402
user2273893 Avatar asked Apr 12 '13 10:04

user2273893


People also ask

How do I move files from one folder to another in script?

You can automatically move files from one folder to another by using a script that uses Robocopy, a command-line utility which comes with Windows 10. To automated file transfer, you need to use Robocopy script, add frequency in days, source and destination folder paths.

How do I move files in CMD?

Highlight the files you want to move. Press the keyboard shortcut Command + C . Move to the location you want to move the files and press Option + Command + V to move the files.


1 Answers

Create a file called MoveFiles.bat with the syntax

move c:\Sourcefoldernam\*.* e:\destinationFolder

then schedule a task to run that MoveFiles.bat every 10 hours.

like image 80
SwampYeti Avatar answered Sep 30 '22 02:09

SwampYeti