Search found 244 matches

by Endoro
16 Aug 2013 02:08
Forum: DOS Batch Forum
Topic: Fastest way to extract IP:port occurances any text file?
Replies: 16
Views: 9085

Re: Fastest way to extract IP:port occurances any text file?

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).
by Endoro
15 Aug 2013 07:47
Forum: DOS Batch Forum
Topic: Fastest way to extract IP:port occurances any text file?
Replies: 16
Views: 9085

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
by Endoro
15 Aug 2013 04:23
Forum: DOS Batch Forum
Topic: Fastest way to extract IP:port occurances any text file?
Replies: 16
Views: 9085

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,...
by Endoro
15 Aug 2013 00:35
Forum: DOS Batch Forum
Topic: Fastest way to extract IP:port occurances any text file?
Replies: 16
Views: 9085

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'.

Code: Select all

grep -Po "(\d+\.){3}\d+:?(\d?){4}" "file"

This is extremely fast.
by Endoro
10 Aug 2013 13:37
Forum: DOS Batch Forum
Topic: Batch commands fail when parsing large text files.
Replies: 2
Views: 1238

Re: Batch commands fail when parsing large text files.

foxidrive wrote:BTW, your code is missing some " quotes Endoro..

Thanks foxidrive, it works now :oops:
by Endoro
10 Aug 2013 00:01
Forum: DOS Batch Forum
Topic: Batch commands fail when parsing large text files.
Replies: 2
Views: 1238

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...
by Endoro
09 Aug 2013 02:31
Forum: DOS Batch Forum
Topic: Code broken? My stupid logic error
Replies: 2
Views: 1351

Re: Code broken? My stupid logic error

you need delayed expansion :)

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.
by Endoro
12 Jul 2013 15:01
Forum: DOS Batch Forum
Topic: for /F "delims=text" comment
Replies: 3
Views: 1796

Re: for /F "delims=text" comment

I knew it. We had this recently at stackoverflow :wink:
by Endoro
05 Jul 2013 16:44
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

Re: Rename files - # of week

This script does not change anything on system variables or browsers or something else.
by Endoro
05 Jul 2013 16:20
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

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+...
by Endoro
05 Jul 2013 16:01
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

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-...
by Endoro
05 Jul 2013 15:45
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

Re: Rename files - # of week

What ist the output of

Code: Select all

echo %date%
by Endoro
05 Jul 2013 15:35
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

Re: Rename files - # of week

But you have only 3 token: "05", "07", and "2013".
by Endoro
05 Jul 2013 14:37
Forum: DOS Batch Forum
Topic: Rename files - # of week
Replies: 15
Views: 4738

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:
sadly it seems it's not working, for some reason
by Endoro
04 Jul 2013 16:12
Forum: DOS Batch Forum
Topic: Fetching specific column from text file using batch file
Replies: 9
Views: 2988

Re: Fetching specific column from text file using batch file

Code: Select all

call:DateToJDN %DATE% JDN5
In this line you can replace the variable %date% with another date in the format YYY-MM-DD.

Code: Select all

SET /a JDN5-=5
For other date differences put hier the new days in, eg. "2".