Search found 199 matches

by Sponge Belly
30 Nov 2013 14:13
Forum: DOS Batch Forum
Topic: Processing text files that have unlimited size lines!
Replies: 24
Views: 8731

Re: Processing text files that have unlimited size lines!

Sorry I’m late! Here’s some beta code that reads in a file containing a single long line (NULs and newlines not supported). It splits it up and spits it back out in 4095-character chunks by misusing pause and find: @echo off & setlocal enableextensions enabledelayedexpansion if "%~1" n...
by Sponge Belly
26 Nov 2013 04:16
Forum: DOS Batch Forum
Topic: question about the "find" command
Replies: 3
Views: 1506

Re: question about the "find" command

Hi AiroNG, :-)

The findstr command will do what you want:

Code: Select all

findstr /l "text" "*.txt"


It will output only the filenames that contain the matching text. Read findstr’s help for more info. There are many switches to be mastered.

Good luck! ;-)

- SB
by Sponge Belly
20 Nov 2013 10:24
Forum: DOS Batch Forum
Topic: truncate files - a (pure?) batch solution
Replies: 3
Views: 5040

Re: truncate files - a (pure?) batch solution

Dear DosTippers, While participating in a long, meandering thread about something else entirely, I prepended a BOM to a plain ASCII file and redirected it to a new file as below: cmd /d /u /c type bomfile.txt > newfile.txt To my surprise, the BOM was missing from the new file and the new file was 1 ...
by Sponge Belly
19 Nov 2013 17:22
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 7471

Re: ctrl-z blues

Hi Again! Thanks to Penpen for the link to the Unicode website and for the information on the Buginese people. It just goes to show you come across the strangest things while trying to learn Batch! But something Penpen said… A UTF-16 character consists of 2, or 4 bytes. If an unfinished UTF16 charac...
by Sponge Belly
12 Nov 2013 08:56
Forum: DOS Batch Forum
Topic: Multi-process Advanced Encryption Standard (AES)
Replies: 51
Views: 26198

Re: Multi-process Advanced Encryption Standard (AES)

Hi Magialisk! I haven’t been following this topic too closely because I know nothing of encryption, but I read your plea for help on how to stop a for /l loop in its tracks. It is possible, but at the expense of starting a subshell. Here's a trivial example: @echo off & setlocal enableextensions...
by Sponge Belly
10 Nov 2013 10:29
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 7471

Re: ctrl-z blues

@Penpen: Thanks for the explanation! What utility did you use to make the Unicode dump? I want it! And what on Earth is Buginese? @Carlos: Thanks for the info on type and for /f loops. Fascinating! As near as I can tell, echo, set, and set /p can correctly process UTF-16 LE strings as well as type. ...
by Sponge Belly
06 Nov 2013 10:36
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 7471

Re: ctrl-z blues

Hi aGerman! :-)

Thanks for spelling out that aspect of fc’s behaviour for me. I should’ve realised it myself, sorry. :oops:

Too many synapses lost to the hard stuff when I was younger… ;-)

- SB

PS: Would still like to know what happened to that Line Feed.
by Sponge Belly
05 Nov 2013 16:34
Forum: DOS Batch Forum
Topic: ctrl-z blues
Replies: 24
Views: 7471

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: 7471

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: 5941

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: 7471

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: 7471

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: 7471

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: 3866

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: 4
Views: 3716

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