Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Have batch file compare outputed text.


  • Please log in to reply
2 replies to this topic

#1 Zestypanda

Zestypanda

  • Members
  • 603 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sunny San Diego, California.
  • Local time:10:44 PM

Posted 01 July 2013 - 07:40 PM

Ok, so some of you know that I'm making a repair toolkit, USB, that uses a batch file to pull down fresh copies of my tools, well how can I get it to check the outputed "%date%" hat will be put into s file called "updated.txt" against current date and if its less than X amount against current date it will update.
Eg: output in file says it was updated 7/1/2013 and system time and date says its 7/13/2013, upon finding that it prompts by doing a goto check then :check has echo your tools are X days old (I don't know how to get x), would you like to update? Then yes or no.

Have a question, or just wanna chat? Send me a message. Or add me as a friend.

 


BC AdBot (Login to Remove)

 


#2 Crazy Cat

Crazy Cat

  • Members
  • 808 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Lunatic Asylum
  • Local time:03:44 PM

Posted 01 July 2013 - 09:32 PM

May I suggest to use the REPLACE command: Replace or update one file with another with the /U : Replace (update) only files that are older than the source.

REPLACE, http://ss64.com/nt/replace.html

Ok, so some of you know that I'm making a repair toolkit, USB, that uses a batch file to pull down fresh copies of my tools, well how can I get it to check the outputed "%date%" hat will be put into s file called "updated.txt" against current date and if its less than X amount against current date it will update.
Eg: output in file says it was updated 7/1/2013 and system time and date says its 7/13/2013, upon finding that it prompts by doing a goto check then :check has echo your tools are X days old (I don't know how to get x), would you like to update? Then yes or no.


Use the COMP, Compare two files (or sets of files). Display items which do not match. http://ss64.com/nt/comp.html

Resources sites.
An A-Z Index of the Windows CMD command line. http://ss64.com/nt/
Windows Batch Scripting. http://en.wikibooks.org/wiki/Windows_Batch_Scripting

Edited by Crazy Cat, 01 July 2013 - 09:55 PM.

 

Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. ― Albert Einstein ― Insanity is doing the same thing, over and over again, but expecting different results.

 

InternetDefenseLeague-footer-badge.png


#3 Crazy Cat

Crazy Cat

  • Members
  • 808 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Lunatic Asylum
  • Local time:03:44 PM

Posted 02 July 2013 - 08:05 PM

Eg: output in file says it was updated 7/1/2013 and system time and date says its 7/13/2013, upon finding that it prompts by doing a goto check then :check has echo your tools are X days old (I don't know how to get x), would you like to update? Then yes or no.


If your Calendar Dates are in Basic Format (YYYYMMDD | Eg 19991231) then you can use simple subtraction to get X.

Or use the DateDiff.bat
 

DateDiff.bat http://www.robvanderwoude.com/datetiment.php#DateDiff

Calculates the difference in days between two dates, and returns the resulting date in a variable name DateDiff.
This batch files accepts dates in the local date format. This independance of international settings is accomplished by using the techniques from IDate.bat and SDate.bat. Internally, the batch file uses Julian dates. Julian date conversions are based on the Fliegel-Van Flandern algorithms from the Astronomical Almanac, provided by Doctor Fenton on the Math Forum and converted to batch code by Ron Bakowski.


Suggested Formats: This is basically a very brief summary of the most commonly used date and time formats suggested by ISO 8601.

Calendar Date Basic Format Extended Format
YYYYMMDD Eg 19991231 YYYY-MM-DD Eg 1999-12-31

http://www.commandline.co.uk/cmdfuncs/dandt/index.html
 

Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. ― Albert Einstein ― Insanity is doing the same thing, over and over again, but expecting different results.

 

InternetDefenseLeague-footer-badge.png





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users