How do I get the number of s in file.txt?
Full File:
echo/%f|findstr /b /c:"%ref_no%" >nul
if not errorlevel 1 (
echo/%f%s >>file.txt
) else echo/%f >>file.txt
)
echo :: How many times you used s in file.txt
FindStr /B /C:s file.txt | Find /C "s"
ping -n 2 127.0.0.1>nul
echo :: Done.
ping -n 2 127.0.0.1>nul
pause
and in file.txt lets say u say
s
s
s
It should come up in batch like this.
echo :: How many times you used s in file.txt
3
3<<< ??Now how do I get this number in a .txt file from batch file??
I know how to do
echo/%f|findstr /b /c:"%ref_no%" >nul
if not errorlevel 1 (
echo/%f%s >>file.txt
) else echo/%f >>file.txt
)
It must have something to do with echo/%f%s >>file.txt But what? Maybe a Professional will help me.
Thank You
Jessica
How do I do this im terrible at Batch???
Moderator: DosItHelp
Hi soeey again but um... it didnt help much that just shows how many s's are in the file.txt. How would I type file.txt|find /c "s" and get the number of "s" so i can save it in the file.txt from the batch file I made?
Example:
Now next to the s in file.txt i want it to say how many s's were in file.txt.
From the example above I want it like this:
s 1
s 2
s 3
s 4
s 5
Instead of this
s
1
s
2
s
3
s
4
s
5
um.. If its impossible just tell me >.<
Example:
@echo off
echo/%f|findstr /b /c:"%ref_no%" >nul
if not errorlevel 1 (
echo/%f%s>>file.txt
) else echo/%f >>file.txt
)
type file.txt|find /c "s"
type file.txt|find /c "s">>%file.txt
pause
test.bat
Now next to the s in file.txt i want it to say how many s's were in file.txt.
From the example above I want it like this:
s 1
s 2
s 3
s 4
s 5
Instead of this
s
1
s
2
s
3
s
4
s
5
um.. If its impossible just tell me >.<
MAI,
You use some syntax that I'm not familiar with: "echo/%f"
What is %f? should it be %f% (one percent sign missing at the end)?
Well I think I get your point. How about this:
What do you think?
You use some syntax that I'm not familiar with: "echo/%f"
What is %f? should it be %f% (one percent sign missing at the end)?
Well I think I get your point. How about this:
Code: Select all
set "FindIn=sourcefile.txt"
for /f %%N in ('" type "%FindIn%"|find /c "s" "') do set "cnt=%%N"
echo.%FindIn% %cnt%>>file.txt
What do you think?
Last edited by DosItHelp on 01 Sep 2007 23:13, edited 3 times in total.
I tryed it but it dont do anything but say sourcefile.txt with echo off and pause added. That or I dont understand what u mean. Maybe you dont understand what i mean ? >.< copy paste the above one and look in file.txt.
I want it like this:
s 1
s 2
s 3
s 4
s 5
Instead of this
s
1
s
2
s
3
s
4
s
I was also wondering if its possible to make rainbow color (like color 1, color 2, color 3, color 4)in batch well still being able to do commands in a menu in batch. That would be a cool menu but I dont think its possible.
I want it like this:
s 1
s 2
s 3
s 4
s 5
Instead of this
s
1
s
2
s
3
s
4
s
I was also wondering if its possible to make rainbow color (like color 1, color 2, color 3, color 4)in batch well still being able to do commands in a menu in batch. That would be a cool menu but I dont think its possible.
Mai,
Sorry the last line had a space missing.
This counts all lines in sourcefile.txt that have an 's' in it. The result appears in file.txt and on screen.
DosItHelp?
Sorry the last line had a space missing.
Code: Select all
set "FindIn=sourcefile.txt"
for /f %%N in ('" type "%FindIn%"|find /c "s" "') do set "cnt=%%N"
echo.%FindIn% %cnt%
echo.%FindIn% %cnt% >>file.txt
This counts all lines in sourcefile.txt that have an 's' in it. The result appears in file.txt and on screen.
DosItHelp?