Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tscmd42.zip Useful NT/2000/XP script tricks and tips

7 views
Skip to first unread message

Timo Salmi

unread,
Jan 13, 2007, 9:26:16 AM1/13/07
to
Sat 13-Jan-2007: Update
182662 Jan 13 2007 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd42.zip Useful NT/2000/XP script tricks and tips, T.Salmi

The changes include:
MAILDATE.CMD Build a message's "From" header
Added an /SUBJ switch to include the subject from the email header
with the date added.

NAMEDOWN.CMD Covert a filename to lower case
NAMEUP.CMD Covert a filename to upper case
Corrected the bug that caused a failure for filenames with
parentheses.

Added to the FAQ file 1CMDFAQ.TXT
154} How do I remove leading zeros from a string with script only?
155} How can I use command-line to open a Windows Explorer Window?
156} How does one create a stortcut using the command-line?
157} How to get the count of words and the last word of a variable?

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

b.ped...@get2net.dk

unread,
Jan 13, 2007, 9:55:41 AM1/13/07
to

FAQ 106} How to test whether a variable is a non-negative integer?

echo %n%|findstr /r "[^0-9]">nul
if %errorlevel% GTR 0 (set isInteger=true) else (set isInteger=false)

Or this new one:

if "!n:~,1%n%!"=="%n%" (set isInteger=true)else (set isInteger=false)

Benny Pedersen

Herbert Kleebauer

unread,
Jan 13, 2007, 1:24:03 PM1/13/07
to
b.ped...@get2net.dk wrote:

> Or this new one:
>
> if "!n:~,1%n%!"=="%n%" (set isInteger=true)else (set isInteger=false)


@echo off
setlocal enabledelayedexpansion
set n=^^!"=="" (cd) else echo Hello Benny ^& goto :eof

echo - Let's see what Benny's integer test says to the n set above -


if "!n:~,1%n%!"=="%n%" (set isInteger=true)else (set isInteger=false)

echo %isInteger%

Message has been deleted

b.ped...@get2net.dk

unread,
Jan 13, 2007, 6:45:16 PM1/13/07
to

It simply said something like this:

Hello Herbert. I know that you are able to see that
my new syntax is both more brief, faster and better
than the previous one using "findstr.exe",
and that one should NOT put anything into a variable n,
such as:


set n=^^!"=="" (cd) else echo Hello Benny ^& goto :eof

but one should instead input a number when asked.
(set n= input a number, or a letter: )

Anyhow, most menus in programs are NOT about
input a number to erase all data, etc... and
for my current project
(
if a number goto :number, else if it's a letter, then
something else...
), my new found: "!n:~,1%n%!"=="%n%"
is much better. I guess that you do know the bad things
about using a pipe (|), and that it's good if you could
avoid a pipe :-)

This (my) syntax: "!n:~,1%n%!"
Should do a string thing, NOT executing a syntax.!!!
What you said (me) is also that the Microsoft stuff is
bad, and programming in any other language than DOS
is more easy. DOS is the world most hard and difficult
language, that is why we prefer programming in DOS,
not C++, VBS, or whatever....

Benny,
BTW. The previous syntax from Timo would also fail
if the "findstr.exe" file is missing...

b.ped...@get2net.dk

unread,
Jan 13, 2007, 9:16:41 PM1/13/07
to

btw. I also want a 4 digit number n,
so instead of the "findstr.EXE" I could use something like this:

if "!n:~4!" == "" (
for /L %%I in (0,1,3) do ((set v= )
for /L %%E in (0,1,9) do if "%%E" == "!n:~%%I,1!" (set v=)
if defined v echo oops on nth %%I+1
)
) else echo Not defined n, or too long.

Benny,
PS
Herbert could execute whatever n in this: !X:~%n%,1!
so what about this: "!n:~%%I,1!"
Even if he is able to let that one fail, I would still use batch
files...
:-)

Matthias Tacke

unread,
Jan 25, 2007, 9:58:17 AM1/25/07
to
Timo Salmi schrieb:
...

> Added to the FAQ file 1CMDFAQ.TXT

> 156} How does one create a stortcut using the command-line?

Hi Timo,
I guess that should read shortcut not stortcut ;-)

There are several other .exe programs around the net.
From these I like Shortcut.exe from Marty List because it has edit and
query modes. It should also work with all Windows versions up to w2k3.
http://www.optimumx.com/download/

In environments not allowing foreign programs, a vbscript can be used.
http://groups.google.com/groups?q=create+shortcut+vbs+group%3Aalt.msdos.batch.*

When scripting host isn't installed an inf file could be created to install
the link.
http://groups.google.de/groups?q=create+shortcut+inf+group%3Aalt.msdos.batch.*

Greetings
Matthias

Timo Salmi

unread,
Jan 25, 2007, 10:39:19 AM1/25/07
to
Matthias Tacke <Matt...@Tacke.de> wrote:
> Timo Salmi schrieb:

> I guess that should read shortcut not stortcut ;-)

> There are several other .exe programs around the net.

Thank you, Matthias. I have pointed to your useful further information.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland

Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

0 new messages