Solved

Simple file copy login script based on time and date stamp

Posted on 2009-04-09
3
600 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 84

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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