Solved

Script/command to copy File Daily

Posted on 2014-03-06
9
712 Views
Last Modified: 2014-03-07
Need a script or command to copy a file daily and move it to a directory on another server. The script needs to only copy the most recently created file in the directory.

Any ideas how to make this happen?
0
Comment
Question by:sarasotamac
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 13

Assisted Solution

by:Santosh Gupta
Santosh Gupta earned 125 total points
ID: 39909168
0
 
LVL 19

Assisted Solution

by:Kash
Kash earned 125 total points
ID: 39909201
there are couple of ways you can do that.

you can use robocopy or secondly a batch script which can look like below:

copy C:\locationoffiles \\remotemachine\c$\Path\file

or may be use xcopy >>> http://en.kioskea.net/forum/affich-9894-batch-file-to-copy-file-from-one-system-to-on
0
 
LVL 53

Assisted Solution

by:Bill Prew
Bill Prew earned 250 total points
ID: 39909239
This should do it:

@echo off
for /F "tokens=*" %%A in ('dir /b /a-d /tc /od "c:\source\*.*"') do (
  move "c:\source\%%~A" "\\server\sharename\folder"
  goto :Done
)
:Done

Open in new window

~bp
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 6

Author Comment

by:sarasotamac
ID: 39909248
billprew, this is going to only copy the newest file, correct?
0
 
LVL 6

Author Comment

by:sarasotamac
ID: 39909252
Kash, I was thinking of robocopy, as I have used it for large data migrations previously. My only concern is getting it to only move the newest file in the directory.
0
 
LVL 19

Expert Comment

by:Kash
ID: 39909420
if I were you, i would create a PS scripts which would take inputs on how to proceed with data copy. It should not be that hard to create one with couple of hours on hand.

with regards to robocopy, you can modify the selection (files) to copy >>> http://technet.microsoft.com/en-us/library/cc733145.aspx
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 39909930
billprew, this is going to only copy the newest file, correct?

Correct.

~bp
0
 
LVL 6

Author Closing Comment

by:sarasotamac
ID: 39912871
Thanks everyone, I took a little from everyone's answers.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 39912907
Welcome.

~bp
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question