Search found 222 matches

by Sponge Belly
05 Nov 2013 16:34
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 17408

Re: ctrl-z blues

Hi Squashman! Speaking of Line Feeds, I stumbled across some bizarre behaviour in my tests. Create a test file called hi.txt with your favourite text editor: <255><254>hi there<SUB><CR><LF> The first two characters in the file are ASCII 255 and 254. This is known as the Byte Order Mark (BOM) and is ...
by Sponge Belly
04 Nov 2013 17:01
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 17408

Re: ctrl-z blues

Hi Penpen! Thanks for your reply. You were right about saving the file as Unicode (UTF-16). Everything works fine when I do this. SUB doesn’t cause any problems. But I think type is the stumbling block. This works… cmd /d /u /c type unicode.txt > uni.out.txt but this doesn’t: cmd /d /u /c type ansi....
by Sponge Belly
04 Nov 2013 16:22
Forum: DOS Batch Forum
Topic: Change in date input
Replies: 12
Views: 11752

Re: Change in date input

Hi mor.bas! :-)

Use Carlos’s pure Batch getDate function to acquire the date in locale-independent form. Once you have that nailed down, you can use xcopy’s /d switch to validate dates n days ago/from now as detailed in Paul Tomasi’s Validating Dates article.

HTH! ;-)

- SB
by Sponge Belly
02 Nov 2013 17:19
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 17408

Re: ctrl-z blues

Me Again! Thanks aGerman for your suggestion. There was a recent discussion here about using set /p to slurp up long lines 1021 characters at a time. Dave Benham concluded that the method was “lossy” if the line had control characters at the end. Made for interesting reading all the same… And thanks...
by Sponge Belly
02 Nov 2013 13:14
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 17408

Re: ctrl-z blues

Hi Again, Thanks for the replies. The Choice Function thread aGerman pointed to was riveting. How did I miss that? But I’m trying to find a way to use type with cmd /d /u /c so I can read every character in a file one by one. The only thing stopping me is Ctrl-Z (SUB). If the input file contains a S...
by Sponge Belly
02 Nov 2013 08:58
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 17408

ctrl-z blues

Hello All! Imagine a test file called hi.txt with the contents “hi there” (no quotes and no newline). It’s possible to print out the characters of the file one by one using a little trick I learnt from Judago : cmd /d /u /c type hi.txt | find /v "" h i t h e r e This would be extremely use...
by Sponge Belly
23 Oct 2013 12:03
Forum: DOS Batch Forum
Topic: FTP Download only new files any file type
Replies: 7
Views: 7797

Re: FTP Download only new files any file type

Hi Thlockler, Sorry for not replying sooner. I was on my holidays! Anyways, I don’t fully understand your question. The script makes two connections to the ftp host. On the first pass, it builds a list of all files matching the findstr pattern. On the second pass, it downloads only those files that ...
by Sponge Belly
16 Sep 2013 15:35
Forum: DOS Batch Forum
Topic: reverse string without goto
Replies: 10
Views: 14458

reverse string without goto

Building on what I learnt from Dave Benham’s demonstration of escaping special characters inside a for /f loop’s in (…) clause , and Aacini’s use of a for /l loop called by a cmd subshell to emulate a while loop , I’ve cobbled together an alternative method for reversing a string that does not requi...
by Sponge Belly
10 Aug 2013 15:50
Forum: DOS Batch Forum
Topic: strimmer: a string trimmer
Replies: 5
Views: 6594

Re: strimmer: a string trimmer

Thanks for the explanation, Jeb! :-)

- SB
by Sponge Belly
10 Aug 2013 13:40
Forum: DOS Batch Forum
Topic: vagaries of for /f loops
Replies: 4
Views: 4211

Re: vagaries of for /f loops

Thanks Penpen and Dave! In the second example, multiple parameter separators (, ; = <SP> and <TAB>) are indeed replaced with a single space… but not dots. Note that if you quote the string, any leading whitespace and the opening quote itself will be stripped away and the rest of the string will be d...
by Sponge Belly
07 Aug 2013 09:15
Forum: DOS Batch Forum
Topic: strimmer: a string trimmer
Replies: 5
Views: 6594

Re: strimmer: a string trimmer

Thanks Penpen…

Edit: Please read revised code.

- SB
by Sponge Belly
03 Aug 2013 16:20
Forum: DOS Batch Forum
Topic: strimmer: a string trimmer
Replies: 5
Views: 6594

strimmer: a string trimmer

Hi All! :-)

Below is an alternative technique for trimming leading and trailing spaces and tabs from a string…

Edit: Please read revised code.

- SB
by Sponge Belly
01 Aug 2013 08:22
Forum: DOS Batch Forum
Topic: vagaries of for /f loops
Replies: 4
Views: 4211

vagaries of for /f loops

Dear DosTips, I came across something puzzling while researching an alternative method of trimming whitespace (spaces and/or tabs) from the head and tail of a string. To trim any whitespace on the left of a string, simply do this: for /f "tokens=*" %%a in ("%string%") do set &quo...
by Sponge Belly
09 Jul 2013 18:40
Forum: DOS Batch Forum
Topic: how to read input from a pipe
Replies: 9
Views: 8581

Re: how to read input from a pipe

Hello Sambasiva! :-)

I recommend the find or findstr prompt issue topic. See my contribution at the end. :D

If you have any further questions, don’t hesitate to ask.

- SB
by Sponge Belly
09 Jul 2013 18:26
Forum: DOS Batch Forum
Topic: Some Explaination on these
Replies: 6
Views: 5420

Re: Some Explaination on these

Hello Flora! This line of code is a clever but ugly hack: SET v=%v:;=&rem.% It has the effect of discarding everything in the string after the first occurrence of semi-colon (inclusive). It is the opposite of: SET v=%v:*;=% which removes everything before the first occurrence of a semi-colon (se...