| 1. |
Solve : Batch for comparing values? |
|
Answer» Hi people. I need some help if someone can help me? Need just one more thing here if you are willing to help. I'm glad it helps. When you ask for free help then you should write the whole task out with as much information that you can provide. Asking for more changes once you get some tested code that works means even more work for the people helping you, as they have to change the code that is already written and tested, and then test it again. sorry about that you are right. But that crossed my mind after I tested this. I didn't think about the whole process. Sorry againCan I still hope for help for that?This runs myapp 3 times, then runs mynextapp 3 times, then relaunches the batch file. It only launches the apps if the average figure is less than the figure in compare.txt Code: [Select]echo off :: initialise the app counter files if not exist "app1.txt" type nul >"app1.txt" if not exist "app2.txt" type nul >"app2.txt" if not exist "compare.txt" echo compare.txt is missing&pause&goto :EOF :: If app1 has run 3 times then set the variable to app2 (otherwise set it to app1) find /c "run" <"app1.txt" | find "3" >nul && (set app=app2) || (set app=app1) :: If app2 has run 3 times then remove the counter files and relaunch the batch file find /c "run" <"app2.txt" | find "3" >nul && ( del "app1.txt" "app2.txt" %0 ) :: get the average figure from the last line in the file for /f "usebackq tokens=5 delims=:. " %%a in ("myfile.log") do set avg=%%a echo avg="%avg%" :: get the compare number from the file and if avg is lower, :: increment the counter file and run the app - using the app as defined above. for /f "usebackq delims=" %%a in ("compare.txt") do if %avg% LSS %%a ( if "%app%"=="app1" >>"app1.txt" echo run& start "" "c:\program files\folder\myapp.exe" if "%app%"=="app2" >>"app2.txt" echo run& start "" "c:\program files\folder\mynextapp.exe" ) Thank you, you really made my day today, finally works all like I wanted. Thank you If I can ask for more help here not to opening new topic? I need one mora batch file for copying the newest file from folder login to folder test\new is it possible to have just a PART of path in batch not full path? because I need to make bach fule for each user if it is not possible just part of path. because full path is c:\users\mike\software\screener\database\database2014\office\login c:\users\mike\software\screener\database\database2014\office\test\newOpen a new topic for different questions. They are free. If this is run from the login folder then it will copy the newest file to the new folder SHOWN in your path. Code: [Select]echo off for /f "delims=" %%a in ('dir /b /od /a-d') do set "lastest_file=%%a" copy "%lastest_file%" "..\test\new" Didn't know about opening new topic because on some forums doesn't like to have every question new topic. This batch not working it copy only itself to folder test\new that also is not ok because there must be only one file I runned this from \login folder where batch file should be |
|