Search found 2267 matches

by dbenham
11 May 2011 15:06
Forum: DOS Batch Forum
Topic: Sort tokens within a string & Disable FOR /F EOL option
Replies: 9
Views: 7895

Sort tokens within a string & Disable FOR /F EOL option

2011-07-10: Changed title to reference discussion of FOR /F EOL option which begins in 3rd post on this thread While working on a "universal" %DATE% parser it became necessary to sort tokens within a string. A few techniques were briefly bandied about that all relied on a fixed small numb...
by dbenham
10 May 2011 21:43
Forum: DOS Batch Forum
Topic: "universal" %DATE% parser
Replies: 17
Views: 12195

"universal" %DATE% parser

There are many situations where %DATE% must be parsed into numeric year, month, and day components. But the format of %DATE% is highly variable depending on locality and personal preference. It is fairly easy to develop custom code for each individual situation. But it would be great to have a "...
by dbenham
10 May 2011 21:33
Forum: DOS Batch Forum
Topic: md and move Help experts
Replies: 20
Views: 6828

Re: md and move Help experts

Thanks aGerman for your clear explanations.

Armed with your information I think I have developed the beginnings of a true "universal" date parser that does not need access to the registry. I'll post it on a new thread.

Dave Benham
by dbenham
10 May 2011 12:48
Forum: DOS Batch Forum
Topic: md and move Help experts
Replies: 20
Views: 6828

Re: md and move Help experts

Hi aGerman From an early post in this thread As I explained so many times DateTime (type of data) values are unknown for a batch code. What you can find in variable %date% is only a string of characters. It depends on your registry settings how it looks like (the order of year, month and day as well...
by dbenham
09 May 2011 22:24
Forum: DOS Batch Forum
Topic: toLower Name dependent?
Replies: 16
Views: 6165

Re: toLower Name dependent? - proposed bug/limitation fix

Good catch WernerGg - you have discovered a limitation/bug in the existing :toLower code and come up with a working fix. Given that your modified code is already using SETLOCAL ENABLEDELAYEDEXPANSION, the following two lines: set str=%~1 call set "str=%%%str%%%" can be replaced by the much...
by dbenham
09 May 2011 03:46
Forum: DOS Batch Forum
Topic: Access complex parameters
Replies: 15
Views: 6459

Re: Access complex parameters

"DOS" is seriously whacked! (as if we didn't already know this) Extra escapes enable us to read evidence of multiple LFs, but not the LFs themselves. test1.bat @echo off cls setlocal enableDelayedExpansion set lf=^ set "var=Line1^^^^^^!lf!!lf!^^^^^^!lf!!lf!Line3^^^^^^!lf!!lf!^^!lf!!lf...
by dbenham
04 May 2011 06:45
Forum: DOS Batch Forum
Topic: Searching for a line
Replies: 3
Views: 1772

Re: Searching for a line

Why use batch to extract the value if you are already using VB Script? The FileSystemObject and TextStream objects allow you to open and read a text file directly within VB Script.

Dave
by dbenham
03 May 2011 11:54
Forum: DOS Batch Forum
Topic: Searching for a line
Replies: 3
Views: 1772

Re: Searching for a line

For this example, assume data is in data.txt in current directory. Assuming that neither name nor value will ever contain a space or colon, then the following should work: @echo off set VAL= set SAVE= for /f "tokens=2,3 delims=: " %%a in ('findstr /b /c:"Variable name : " /c:&quo...
by dbenham
29 Apr 2011 12:53
Forum: DOS Batch Forum
Topic: How to extract characters from a string
Replies: 1
Views: 1545

Re: How to extract characters from a string

Starting with set today=%date% set mth=%today:~4,2% set mths=janfebmaraprmayjunjulaugsepoctnovdec SET /A posn=100%mth%%%100*3-3 ... you have several options: without delayed expansion call set mmm=%%mths:~%posn%,3%% The variables are expanded in two passes because of the CALL. After the first pass %...
by dbenham
28 Apr 2011 21:20
Forum: DOS Batch Forum
Topic: New function - :hexDump
Replies: 10
Views: 11330

Re: New function - :hexDump

Thanks for testing nitt, but I am unable to reproduce your results. I copied your test source code into a file named original.txt and then ran the following test.bat setlocal enableDelayedExpansion call hexdump /b0 original.txt >original.hex echo on for /f %%h in ('type original.hex') do set hex=%%h...
by dbenham
27 Apr 2011 23:57
Forum: DOS Batch Forum
Topic: New function - :hexDump
Replies: 10
Views: 11330

New function - :hexDump

A much faster version of HEXDUMP.BAT based on CERTUTIL is available at https://www.dostips.com/forum/viewtopic.php?f=3&t=8816 Jeb posted a clever technique for reading binary files as an addendum to the ROT13 encryption thread . I've expanded the concept into a flexible hexDump routine with a good ...
by dbenham
27 Apr 2011 23:37
Forum: DOS Batch Forum
Topic: Simple batch Cryptography: howto crypt / decrypt ROT13:
Replies: 32
Views: 21457

Re: Simple batch Cryptography: howto crypt / decrypt ROT13:

Thanks for the feedback aGerman Jeb - I don't see the point in making further modifications to ROT13. It is not really appropriate for binary files. As far as I'm concerned the final version at the end of page 2 is "production ready". That being said, your binary file reader is very intere...
by dbenham
26 Apr 2011 17:37
Forum: DOS Batch Forum
Topic: Encode and Decode Strings
Replies: 5
Views: 3193

Re: Encode and Decode Strings

Thanks aGerman - I'll use that next time I post a link.

Dave
by dbenham
26 Apr 2011 12:07
Forum: DOS Batch Forum
Topic: Simple batch Cryptography: howto crypt / decrypt ROT13:
Replies: 32
Views: 21457

Re: Simple batch Cryptography: howto crypt / decrypt ROT13:

I optimized the functions from my prior post to be fully self contained (no dependencies) and to use a more efficient transformation map. An additional benefit is I can now post the code here without corruption. Function :rot13F is now able to process a 26kb file in 9 seconds. Not bad for musty old ...
by dbenham
25 Apr 2011 19:40
Forum: DOS Batch Forum
Topic: Encode and Decode Strings
Replies: 5
Views: 3193

Re: Encode and Decode Strings

I've posted a link to an efficient ROT13 encryption routine at the end of the thread that aGerman referenced. It is able to encrypt a 26k file in around 30 seconds. The code is embedded in a larger library of routines with documentation included. The actual file encryption takes roughly 65 lines of ...