0

I'd like to create a batch file to copy the files and folders by specific days. For example, 15th and 30th of the month(not 15th to 30th) copy the files and folder to another location. How can I write this script with xcopy or robocopy utility?

Thanks

AlirezaK
  • 316
  • 3
  • 20
fedora
  • 11
  • 5

1 Answers1

1

You can use the below command in a text file:

robocopy sourcePath destinationPath *.* /e /r:0 /w:0 /np

Then save the text file and change the file to cmd file.

After that, you can create a scheduled task and configure it to run in 15th and 30th every month (on Trigger tab). You can add the above command in the Actions tab.

AlirezaK
  • 316
  • 3
  • 20
  • I have windows server 2003 in my network. I don't think robocopy work in the windows server 2003. Also, I don't want to copy all of the files and folders. – fedora Jan 26 '19 at 13:20
  • Please clarify your question. you said `with xcopy or robocopy` and you didn't say which OS that you have used, however, you can download the `Windows Server 2003 Resource Kit Tools` and use it to achieve `robocopy`. https://www.microsoft.com/en-us/download/details.aspx?id=17657 – AlirezaK Jan 27 '19 at 04:54
  • If you wouldn't like to copy all files you can put your file name instead of `*.*` for more information about `robocopy` syntax please refer to this link. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy – AlirezaK Jan 27 '19 at 05:05
  • Thanks Tom for your time, Can I do that without using scheduled task and I specify that log the event every time copies done? – fedora Jan 27 '19 at 11:32
  • Can anyone help me? – fedora Jan 28 '19 at 15:58
  • @fedora, It's another question and it's better to ask it separately. – AlirezaK Jan 29 '19 at 05:37
  • @fedora, you need a script to be run on schedule. This is *exactly* what Windows Task Scheduler exists for and it's really quite good at it. If you are up for a Linux analogy (given your name/avatar), Scheduler is basically a crond on steroids. – Angstrom Feb 05 '19 at 10:50