Solved

Simple file copy login script based on time and date stamp

Posted on 2009-04-09
3
597 Views
Last Modified: 2012-05-06
Hi Experts.
Im looking for a simple login script that will copy one file from a unc share on a server to the users local program files directory based on the date and time stamp...
If the file in the share is newer than the one located in the users program files folder than the file is copied over...if it is the same date than the copy command is ignored.

Something like the code below works put i dont know how to do based on checking the date and time stamp.

Thanks for your advice :)
If exist \\server\share\file.txt goto copy

exit

:copy

copy \\server\share\file.txt "c:\program files\vendor\app\file.txt"

exit

Open in new window

0
Comment
Question by:MVDRUM
3 Comments
 
LVL 14

Expert Comment

by:yehudaha
ID: 24113887
what do you mean newer ?

date last modified ? access ? created ?
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 24114448
Simply use xcopy with the /d switch; this will copy the file only if it's newer than the destination file.
Your script can be shortened a bit, too.
- always put quotes around paths, whether you need them at the moment or not, just to get used to it; they don't hurt if they're not needed.
- you should use "%ProgramFiles%" instead of hardcoding the program folder name
- No need for "exit" at the end of a batch script, it's just annoying if you're testing a script from the command line and have to re-open the command line all the time. If a batch script is started externally (as logon script, for example), the shell window simply closes when it's finished.

If exist "\\server\share\file.txt" xcopy "\\server\share\file.txt" "%ProgramFiles%\vendor\app\file.txt" /d

Open in new window

0
 

Author Closing Comment

by:MVDRUM
ID: 31568818
Excellent adivice/answer oBdA !
Thanks for the explanations along with the answer !!
Muchly apreciated !
spot on !
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

947 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

21 Experts available now in Live!

Get 1:1 Help Now