Solved

Script/command to copy File Daily

Posted on 2014-03-06
9
690 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 51

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
 
LVL 6

Author Comment

by:sarasotamac
ID: 39909248
billprew, this is going to only copy the newest file, correct?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 51

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 51

Expert Comment

by:Bill Prew
ID: 39912907
Welcome.

~bp
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now