How-to: Lower case a String - ToLower.cmd

This function can be used to return a string converted to be lower case.

@Echo off
:: Convert the supplied environment variable (%1) to lowercase.
:: This may be slow for very long strings.
FOR %%G IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO CALL Set _in=%%_in:%%G=%%G%%
Call Echo %%%1%%

By passing a variable, rather than a raw text string, this is able to handle many special punctuation characters.


@Echo off
Set _myvar="This is A DEMO STrIng!"
Call ToLower.cmd _myvar
Echo [%_myvar%]

C:\> this is a demo string!

“Phrasing is the idea of finding sentences and using punctuation in speech. I often look at the score to see what's written in by the composer to see if I can find clues to those directions, like what direction did the composer have in mind, and I try to incorporate those things as much as possible” ~ Hilary Hahn

Related commands:

How-to: VarSubstring - Extract part of a variable (substring)
How-to: VarSearch - Search & replace part of a variable.
String Manipulation - Split, indexof, lastindexof, reverse, endsWith, startsWith - SS64 forum
Tail/Head - SS64 forum
ToUpper - DosTips script to make a string uppercase.

Copyright © 1999-2022
Some rights reserved