Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script/command to copy File Daily

Posted on 2014-03-06
9
Medium Priority
?
778 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 58

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 58

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 58

Expert Comment

by:Bill Prew
ID: 39912907
Welcome.

~bp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

618 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