[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Script/command to copy File Daily

Posted on 2014-03-06
9
Medium Priority
?
806 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 500 total points
ID: 39909168
0
 
LVL 19

Assisted Solution

by:Kash
Kash earned 500 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 59

Assisted Solution

by:Bill Prew
Bill Prew earned 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 59

Accepted Solution

by:
Bill Prew earned 1000 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 59

Expert Comment

by:Bill Prew
ID: 39912907
Welcome.

~bp
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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...
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
Suggested Courses

834 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