19

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.

5
  • 1
    Have you tried anything? Please read How to Ask. Commented Apr 12, 2013 at 10:27
  • 1
    Welcome to SO. This is a Q&A site. Try some code, and come back if you have questions. Commented Apr 12, 2013 at 10:27
  • 1
    Hint: try move /? and schtasks /? Commented Apr 12, 2013 at 11:14
  • Hi I know the move command move Source Destination. But i need the command to move files every 10hours Commented Apr 12, 2013 at 12:14
  • 2
    For that, have you tried schtasks /? ? Commented Apr 12, 2013 at 12:36

4 Answers 4

19

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.

Sign up to request clarification or add additional context in comments.

Comments

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

^ This did not work for me for some reason

But when I tried using quotation marks, it suddenly worked:

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

I think its because my directory had spaces in one of the folders. So if it doesn't work for you, try with quotation marks!

Comments

7

This is exactly how it worked for me. For some reason the above code failed.

This one runs a check every 3 minutes for any files in there and auto moves it to the destination folder. If you need to be prompted for conflicts then change the /y to /-y

:backup
move /y "D:\Dropbox\Dropbox\Camera Uploads\*.*" "D:\Archive\Camera Uploads\"
timeout 360
goto backup

Comments

6

You can try this:

:backup move C:\FilesToBeBackedUp\*.* E:\BackupPlace\ timeout 36000 goto backup

If that doesn't work try to replace "timeout" with sleep. Ik this post is over a year old, just helping anyone with the same problem.

1 Comment

almost 10 years after you did help someone :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.