finding a numerical string range in a text file with batch - batch-file

I have a very basic batch file that basically just pings Google then logs the results in a text file which I have been using as a simple way of testing WiFi connection consistency.
What I'm trying to do is make a second batch file that searches the log txt for any lost packets ranging from 1-4 or find a % loss greater than 0 (outputing results in a second txt file would be a plus too) but I'm not quite knowledgeable in batch so any help would be greatly appreciated.

Related

FINDSTR in batch file to search some directories and using a file to input the search strings

I can only use Windows command line commands for this as program is running forensics in a Windows batch file only to extract information.
I want the user to be able to populate a file with keywords (strings) as keywords.txt that they want to search for.
I only want to search some directories which will popular locations to store user items hence directorylist.txt.
I then want to output any findings into a text file Found_Keywords.txt.
I have been using
FINDSTR /R /I /M /G:C\Users\Admin1\Desktop\Keywords.txt /D:C:\Users\Admin1\Desktop\DirectoryList.txt >C:\Users\Admin1\Desktop\Found_Keywords.txt
Pause
This doesn't appear to work. I have tried sampling the code in other formats and running tests where I search for a string against a given file that contains that string and still no results.
Can anyone suggest where I am going wrong please.
In essence I want someone else to be able to perform keyword searches on a computer against user generated files such as word docs, text, docs and filenames.
Can anyone suggest where I am going wrong please.

Batch file to save all opened files and then shutdown system

I did not find a solution online, so I will ask it here.
I would like to create a batch file that will save all openend work (for example: An opened and unsaved Word document). After it saves all opened work (with added an timestamp or a text with 'autosave'), it must shutdown.
The last part I can make myself (shutdown -t 0), but the first part is too difficult for me.
Do you have any solution?
Thank you for considering my question,
ButerBreaGrieneTsiis

Batch Scripts - Alternative Output to Notepad?

Good Afternoon,
Basically, I have a batch script that does the following:
Pings multiple network machines
Writes the result to a txt file
Searches the created txt file for certain keywords, then outputs that to a separate txt file
Displays the 2nd txt file
It's all very nice and lovely, basically if the machine pings fine then all it shows is the "Pinging xxxxx [10.xxx.xxx.xxx] with 32 bytes of data:" & "Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)" lines.
If it detects anything other than a good ping, it will report the error message in addition to the 2 lines above.
Which leads me to the question...
Is there an alternative output to notepad for the log file? The information that is displays is exactly what I need, but because it's pinging 20+ assets it looks extremely cluttered and ugly. Are there any decent alternatives to display the log file?
Apologies if this is a stupidly basic question, it's after lunch so my brain is only functioning at 0.01% of it's usual power...
I made good experience with writing a .tex file and compiling it with latex (or its derivatives) into a .pdf file. Also, I use a bash script to write a .html document. An .xml file is a nice way to provide the data and an associated .xsl style sheet will add the appropriate visual representation.

How to log input and output of a batch file to a text file?

I have created a batch file with 2000 lines of code and which will peroform various operations in my daily work. For this batch file I have to give some inputs to enable/disable some of the operations. Finally the batch file is ready and working fine.
But I want to have a log file in which everything which is coming on the command window should be logged, including the inputs that I have given to the batch file and also the execution process.
Is there any way do like this? Any one of you can help me?
Thanks in advance...
Nagaraju
You are not telling how you are invoking the batch file. You could try adding redirection to the command line (batchfile.bat > filename.log), although that won't catch whatever you type in as input. You could, however, change the script to print out the input parameters so that they could be caught in the log file.

Watcher batch file for .txt cloning/reseting/modification

I am trying to create a batch file that works something like a watcher, here is what I am trying to do:
The batch keeps monitoring a .txt file for any modification.
Once the file has been modified by any reason, the batch file proceeds with its function.
The function can vary, either change/replace/delete a line of text inside the file or replace the actual .txt file with a previous clone of it.
After this it keeps monitoring, the cycle repeats itself to prevent the file from being modified.
I do not understand anything of batch, I have tried to find guides and ways of doing it but I am really confused so if anyone could help me with this (a guide explaining how to or the actual final batch) I would be very grateful.
Thank you for your time and patience!
Batch file article on Wikipedia will give you enough information to start understanding batch files.
There is a basic example with explanation that will be helpful getting started with running batch file.
Also take a look at the resources mentioned at the Stack Overflow Batch tag info
Once you know how to write batch files, look for commands that you will require to complete your task.

Resources