?
Solved

Script/command to copy File Daily

Posted on 2014-03-06
9
Medium Priority
?
763 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 56

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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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 56

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 56

Expert Comment

by:Bill Prew
ID: 39912907
Welcome.

~bp
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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...
OfficeMate Freezes on login or does not load after login credentials are input.
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 walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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