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

x
?
Solved

Simple file copy login script based on time and date stamp

Posted on 2009-04-09
3
Medium Priority
?
606 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
[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 Comments
 
LVL 14

Expert Comment

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

date last modified ? access ? created ?
0
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

609 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