Search found 250 matches
- 25 Mar 2022 07:41
- Forum: DOS Batch Forum
- Topic: How to get the number after fail in a string inside a file
- Replies: 8
- Views: 7528
Re: How to get the number after fail in a string inside a file
Or selecting only a line matching that which you've posted, and regardless of the postition or the number of digits… @Echo Off & SetLocal EnableExtensions DisableDelayedExpansion Set "failNumber=" & For /F "Delims=" %%G In ('%SystemRoot%\System32\findstr.exe /IRC:"window\.output\[\"stats\"\] = \[\[...
- 25 Mar 2022 07:40
- Forum: DOS Batch Forum
- Topic: How to get the number after fail in a string inside a file
- Replies: 8
- Views: 7528
Re: How to get the number after fail in a string inside a file
If you're sure that the number is always at the same position, read two characers, and if the second is a comma, use only the first. You know what, this is already ugly (you should rather use a JSON processor). So, let's make it even worse ... <"test.txt" set /p "line=" 2>nul set /a "num=%line:~56%...
- 24 Mar 2022 09:53
- Forum: DOS Batch Forum
- Topic: How to get the number after fail in a string inside a file
- Replies: 8
- Views: 7528
How to get the number after fail in a string inside a file
Hi I got a file (test.txt) which contain a string as below: (Actually it is one line below is word wrap) window.output["stats"] = [[{"elapsed":"01:03:51","fail":8,"label":"Critical Tests","pass":56},{"elapsed":"01:03:51","fail":8,"label":"All Tests","pass":56}],[],[{"elapsed":"01:04:00","fail":8,"id...
- 22 Mar 2022 14:07
- Forum: DOS Batch Forum
- Topic: Scripts to get hour not always correct
- Replies: 4
- Views: 5970
Re: Scripts to get hour not always correct
Thanks Compo! It works....
- 20 Mar 2022 07:50
- Forum: DOS Batch Forum
- Topic: Scripts to get hour not always correct
- Replies: 4
- Views: 5970
Scripts to get hour not always correct
Hi All, I have a script to divide the hour into two periods, from 10-21 set not run, the rest set run as below: SET hour=%time:~0,2% echo %hour% IF %hour% leq 21 ( IF %hour% geq 10 ( SET shouldrun=False echo 1 ) else ( SET shouldrun=True echo 2 ) ) else ( set shouldrun=True echo 3 ) if "%shouldrun%"...
- 15 Feb 2022 14:52
- Forum: DOS Batch Forum
- Topic: Batch file to merge two column strings from two files into one file
- Replies: 4
- Views: 5400
Re: Batch file to merge two column strings from two files into one file
Thanks Penpen for your input! I have exactly number of lines in each files.
- 14 Feb 2022 13:25
- Forum: DOS Batch Forum
- Topic: Batch file to merge two column strings from two files into one file
- Replies: 4
- Views: 5400
Re: Batch file to merge two column strings from two files into one file
Thanks a lot! This is the simplest code ever I see for this solution. Just added the space between
Code: Select all
@echo off
setlocal enabledelayedexpansion
< file2.txt ( FOR /F "delims=" %%G IN (file1.txt) DO (
set /p file2=
echo %%G !file2!
)
)>combined.txt
- 14 Feb 2022 09:32
- Forum: DOS Batch Forum
- Topic: Batch file to merge two column strings from two files into one file
- Replies: 4
- Views: 5400
Batch file to merge two column strings from two files into one file
HI All,. I have been searched up for a batch scripts solution to do the below job: file1.txt which has strings listed as below "12345" "23456" "34567" "45678" file2.txt "abcde" "bcdef" "cdefg" "defgh" Now I would like to merge this two files as one file, in this file the two list of strings also mer...
- 08 Feb 2022 08:58
- Forum: DOS Batch Forum
- Topic: Replace strings scripts not done good job
- Replies: 5
- Views: 4687
Re: Replace strings scripts not done good job
The simplest way to solve your problem is processing the replacement strings from longest to shortest and the simplest way to do that without change the content of "pkg_data_temp.txt" is changing this line: for /f "tokens=1-2 delims=" %%A in (C:\temp\pkg_data_temp.txt) do call :schemes %%A %%B ... ...
- 07 Feb 2022 07:56
- Forum: DOS Batch Forum
- Topic: Replace strings scripts not done good job
- Replies: 5
- Views: 4687
Re: Replace strings scripts not done good job
Thanks @penpen for your finding out the issue. But the content of "pkg_data_temp.txt" is supposed to be not changed manually. I thought that the double quote should do the job as a whole string instead of only parse by comma? " T503-08667-0108,T501-08699-0100,T503-08966-0100 " Is any way we can chan...
- 04 Feb 2022 15:28
- Forum: DOS Batch Forum
- Topic: Replace strings scripts not done good job
- Replies: 5
- Views: 4687
Replace strings scripts not done good job
Hi All, I have one text file (index.txt) need replace strings. And also I have a variable file as pkg_data_temp.txt Now I used this below scripts to replace, and most string works fine except two strings only replaced the first part, the remaining is still old for /f "tokens=1-2 delims=" %%A in (C:\...
- 20 Dec 2021 15:22
- Forum: DOS Batch Forum
- Topic: Why substring "on" or "off" not echo?
- Replies: 2
- Views: 2547
Re: Why substring "on" or "off" not echo?
Hi Jeb,
Thanks for your help.
WY
Thanks for your help.
WY
- 20 Dec 2021 14:10
- Forum: DOS Batch Forum
- Topic: Why substring "on" or "off" not echo?
- Replies: 2
- Views: 2547
Why substring "on" or "off" not echo?
Hi, I have a string as str which containing substring either on or off as below set str=Cha-cana-e2eeconfig-off-unsigned for /f "tokens=1-5 delims=- " %%a in ("%str%") do set fla=%%a&set ca=%%b&set cfg=%%c&set e2ee=%%d&set sign=%%e echo %fla% echo %ca% echo %cfg% echo %e2ee% echo %sign% why I only g...
- 14 Nov 2021 13:22
- Forum: DOS Batch Forum
- Topic: how to solve insert line with <abc>
- Replies: 6
- Views: 4504
Re: how to solve insert line with <abc>
Thanks Steffen! You are absolutely correct. There is a space because of the first line ( set lnum=%%i ).
Appreciated!
Appreciated!
- 12 Nov 2021 12:33
- Forum: DOS Batch Forum
- Topic: how to solve insert line with <abc>
- Replies: 6
- Views: 4504
Re: how to solve insert line with <abc>
Since the number of that string can be changed from times to times, so we can not hard coded the line as original code. Now I modify the code as below, but not working, what could be wrong FOR /F "delims=: tokens=1*" %%i in ('findstr /N /I "acq_device_id" "apex_merchant_1_single_chase.xml"') do ( se...