Advertisement
T3RRYT3RR0R

Batch case conversion Macro

May 26th, 2020
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.75 KB | None | 0 0
  1. @ECHO OFF  
  2.     Setlocal DisableDelayedExpansion
  3.  
  4.     (Set LF=^
  5.  
  6.  
  7.     %= Above Empty lines Required =%)
  8.  
  9.     Set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
  10.  
  11. ::: { Case Conversion Macro %CASE% <Var Name> </U=UPPER /L=lower>
  12.     Set CASE=For %%n in (1 2) Do IF %%n==2 (%\n%
  13.         For /F "Tokens=1,2 Delims=, " %%G in ("!CONVERT!") Do (%\n%
  14.             (IF /I "%%H" == "/U" (For %%x 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 (Set "%%~G=!%%~G:%%x=%%x!")) ^&^& Echo !%%G!)%\n%
  15.             (IF /I "%%H" == "/L" (For %%x 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 (Set "%%~G=!%%~G:%%x=%%x!")) ^&^& Echo !%%G!)%\n%
  16.         )%\n%
  17.     ) Else Set CONVERT=,
  18. ::: }
  19.     Setlocal EnableDelayedExpansion  
  20.     Set /P "String=String: "
  21.     %CASE% String /U
  22.     %CASE% String /L
  23.     Pause > Nul
  24. Exit /B
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement