Jump to content
  • Advertisement
Sign in to follow this  
pipipo

Batch Files Check Date

This topic is 3802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, Can anyone help me.. I need to write up a batch file that will check the date modified of the file in G drive and if it is the same at the one at U drive then it will do nothing. But if it is different than it will copy the G drive file to U drive. Help Needed.. Thanks a million..

Share this post


Link to post
Share on other sites
Advertisement
Assuming windows (does "batch file" apply to other OS?), you can use:

xcopy source destination /D

This should copy the source to the destination, only if source is more recent than destination. Type:

help xcopy

at the dos prompt to see a list of options and their explanations.

Share this post


Link to post
Share on other sites
i tried both the codes u guys gave. but it keep giving me insufficient parameters.

xcopy /D G:\Documents\Daily Updates.xls U:\Upload\Daily Update

Share this post


Link to post
Share on other sites
I think you need to specify the parameters after the source and dest names. Also, you want to use quotes around your paths if they have spaces. So try:

xcopy "G:\Documents\Daily Updates.xls" "U:\Upload\Daily Update" /D

Share this post


Link to post
Share on other sites
Thank you so much.

it works now. my mistake for not adding the ""

i have another question. if my file in G drive is for example FILED and FILEM. but they actually contain the same information just that during month end they will provide me with FILEM. whereas daily they will provide me with FILED. is there a way for me to copy the files and name in under a generic name under U drive.

Share this post


Link to post
Share on other sites
You can copy a whole directory to another directory... not sure how you would selectively sometimes copy FILED and other times FILEM, without just copying the whole directory (getting both files effectively)... at least not without getting fancier in your batch file, or switching to python or C# to do the job.

Share this post


Link to post
Share on other sites
I think this would do the trick - destination will contain the newer of fileD.xls and fileM.xls, renamed to file.xls:


xcopy "G:\Documents\fileD.xls" "U:\Upload\Daily Update\file.xls" /D
xcopy "G:\Documents\fileM.xls" "U:\Upload\Daily Update\file.xls" /D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!