Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
sivasriram
- Posts: 12
- Joined: 30 Aug 2014 10:55
#1
Post
by sivasriram » 30 Aug 2014 11:04
hello guys
given below is my dos command
echo on
cd filelocation
echo umiya >umiya.xls
findstr /R /N "^" file.txt | find /C ":" >>umiya.xls
the execution is correct but the output is something like
umiya
10
i just need it in side by side like
umiya-10
-
aGerman
- Expert
- Posts: 4713
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 30 Aug 2014 15:46
A FOR /F loop enables you to output both the text and your line number.
Code: Select all
for /f %%i in ('type "file.txt"^|find /c /v ""') do >"umiya.xls" echo umiya - %%i
Note that you don't create an Excel file even if you use the xls extension.
Regards
aGerman
-
Yury
- Posts: 115
- Joined: 28 Dec 2013 07:54
#3
Post
by Yury » 30 Aug 2014 23:53
Code: Select all
(
set /p="umiya - "<nul
findstr /rn "^" "file.txt"| find /c ":"
)>"umiya.xls"
or
Code: Select all
(
set /p="umiya - "<nul
type "file.txt"| find /c /v ""
)>"umiya.xls"
or
Code: Select all
(
set /p="umiya - "<nul
more<"file.txt"| find /c /v ""
)>"umiya.xls"
.
-
sivasriram
- Posts: 12
- Joined: 30 Aug 2014 10:55
#5
Post
by sivasriram » 25 Sep 2014 15:33
hello,
here is my code
cd desktop
e:
cd E:\CTS\Data\Mumbai\CORE\MEHSANA\OutBox\Extracts\IW
(
set /p="Meshana - "<nul
findstr /rn "^" "*25092014*.txt"| find /c ":"
)>"E:\counts\extract-count.xls"
cd ../../../../
cd E:\CTS\Data\Mumbai\CORE\Varachha Bank\OutBox\Extracts\IW
(
set /p="Varacha - "<nul
findstr /rn "^" "*25092014*.txt"| find /c ":"
)>>"E:\counts\extract-count.xls"
cd ../../../../
cd E:\CTS\Data\Mumbai\CORE\SURAT DIST CO-OP BANK\OutBox\Extracts\IW
(
set /p="surat-dist - "<nul
findstr /rn "^" "*250914*.txt"| find /c ":"
)>>>"E:\counts\extract-count.xls"
cd ../../../../
cd E:\CTS\Data\Mumbai\CORE\UMIYA\OutBox\Extracts\IW
(
set /p="umiya - "<nul
findstr /rn "^" "*25092014*.txt"| find /c ":"
)>>>>"E:\counts\extract-count.xls"
cd ../../../../
THE CODE MENTIONED ABOVE IS WRITING VALUES FOR FIRST 2 FILES CORRECTLY BUT FOR 3RD AND 4TH IT WAS NOT ENTERING ANY RECORDS AND ERROR APPEARING LIKE THIS IN DOS
> was unexpected at this time.
SOME ONE PLEASE HELP TO SOLVE THIS
-
sivasriram
- Posts: 12
- Joined: 30 Aug 2014 10:55
#6
Post
by sivasriram » 25 Sep 2014 15:43
i NEED OUTPUT LIKE
MESHANA-5269
VARACHA-2452
SURAT-5626
UMIYA-45
BUT THE MENTIONED CODE IS WRITING ONLY FIRST TWO RECORDS AND NOT FETCHNING RECORDS FROM 3RD ONE.
-
Compo
- Posts: 600
- Joined: 21 Mar 2014 08:50
#7
Post
by Compo » 25 Sep 2014 17:48
sivasriram wrote:THE CODE MENTIONED ABOVE IS WRITING VALUES FOR FIRST 2 FILES CORRECTLY BUT FOR 3RD AND 4TH IT WAS NOT ENTERING ANY RECORDS AND ERROR APPEARING LIKE THIS IN DOS
> was unexpected at this time.
SOME ONE PLEASE HELP TO SOLVE THIS
Change
>>> to
>>and
Change
>>>> to
>>
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#8
Post
by Squashman » 25 Sep 2014 20:12
sivasriram wrote:hello,
here is my code
How about using code tags when you post code.