Batch is just not a word processor like Word.
For such tasks may be to switch to another tool, e.g. grep, sed, awk or Perl, all available for Windows.
Or you take one of the VBS solutions from dostips (example).
Search found 244 matches
- 16 Aug 2013 02:08
- Forum: DOS Batch Forum
- Topic: Fastest way to extract IP:port occurances any text file?
- Replies: 16
- Views: 18497
- 15 Aug 2013 07:47
- Forum: DOS Batch Forum
- Topic: Fastest way to extract IP:port occurances any text file?
- Replies: 16
- Views: 18497
Re: Fastest way to extract IP:port occurances any text file?
This works for IP:port
Code: Select all
grep -Po "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(\d?){5}" file
- 15 Aug 2013 04:23
- Forum: DOS Batch Forum
- Topic: Fastest way to extract IP:port occurances any text file?
- Replies: 16
- Views: 18497
Re: Fastest way to extract IP:port occurances any text file?
@penpen our codes might be suboptimal but working for most real cases, but yours doesn't work ever. grep -Po "((\d+){3}\.){3}(\d+){3}(:(\d+){5})?" "file" But if you dont't want to find '299.222.7.123:8080' you need more than Regex, you need the ability to calculate. And moreover,...
- 15 Aug 2013 00:35
- Forum: DOS Batch Forum
- Topic: Fastest way to extract IP:port occurances any text file?
- Replies: 16
- Views: 18497
Re: Fastest way to extract IP:port occurances any text file?
Code for GNU grep for Windows.
It can also find IP's without port numbers, e.g. '129.16.0.129'.
This is extremely fast.
It can also find IP's without port numbers, e.g. '129.16.0.129'.
Code: Select all
grep -Po "(\d+\.){3}\d+:?(\d?){4}" "file"
This is extremely fast.
- 10 Aug 2013 13:37
- Forum: DOS Batch Forum
- Topic: Batch commands fail when parsing large text files.
- Replies: 2
- Views: 2943
Re: Batch commands fail when parsing large text files.
foxidrive wrote:BTW, your code is missing some " quotes Endoro..
Thanks foxidrive, it works now
- 10 Aug 2013 00:01
- Forum: DOS Batch Forum
- Topic: Batch commands fail when parsing large text files.
- Replies: 2
- Views: 2943
Batch commands fail when parsing large text files.
At first I make a large text file: (for /l %%a in (1,1,16000) do @echo(0123456789012345678901234567890123456789)>file and test some commands from a batch file @echo off &SETLOCAL SET section=123" SET target=456" SET base=file" ECHO start for /F "delims=:" %%a in ('findst...
- 09 Aug 2013 02:31
- Forum: DOS Batch Forum
- Topic: Code broken? My stupid logic error
- Replies: 2
- Views: 3007
Re: Code broken? My stupid logic error
you need delayed expansion
.. or move the code out of the if-codeblock.
set /a doesn't work with decimal numbers.
Code: Select all
setlocal enabledelayedexpansion
...
set "OSversionRe=!OSversion!"
...
set "OSversionRe=!OSversion!.!OSsubversion!"
.. or move the code out of the if-codeblock.
set /a doesn't work with decimal numbers.
- 12 Jul 2013 15:01
- Forum: DOS Batch Forum
- Topic: for /F "delims=text" comment
- Replies: 3
- Views: 3619
Re: for /F "delims=text" comment
I knew it. We had this recently at stackoverflow
- 05 Jul 2013 16:44
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
This script does not change anything on system variables or browsers or something else.
- 05 Jul 2013 16:20
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
@echo off &SETLOCAL for /F "tokens=1-4 delims=. " %%d in ("fri 05.07.2013") do ( set ddmmyy=%%d %%e.%%f.%%g set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1 ) if %mm% lss 3 set /A mm+=12, yy-=1 set /A a=yy/100, b=a/4, c=2-a+b, e=36525*(yy+4716)/100, f=306*(mm+1)/10, jdn=c+...
- 05 Jul 2013 16:01
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
OK, try this (you can replace "fri 05.07.2013" with "%date%"): @echo off &SETLOCAL for /F "tokens=1-4 delims=. " %%d in ("fri 05.07.2013") do ( set ddmmyy=%%d %%e.%%f.%%g set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1 ) if %mm% lss 3 set /A mm+=12, yy-...
- 05 Jul 2013 15:45
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
What ist the output of
Code: Select all
echo %date%
- 05 Jul 2013 15:35
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
But you have only 3 token: "05", "07", and "2013".
- 05 Jul 2013 14:37
- Forum: DOS Batch Forum
- Topic: Rename files - # of week
- Replies: 15
- Views: 12353
Re: Rename files - # of week
Why does Aacini's answer not work?
Did you get error messages or unexpected results?
This is not helpful, for any reason:
Did you get error messages or unexpected results?
This is not helpful, for any reason:
sadly it seems it's not working, for some reason
- 04 Jul 2013 16:12
- Forum: DOS Batch Forum
- Topic: Fetching specific column from text file using batch file
- Replies: 9
- Views: 7529
Re: Fetching specific column from text file using batch file
Code: Select all
call:DateToJDN %DATE% JDN5
Code: Select all
SET /a JDN5-=5