Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :$: Fun with random strings by T3RRY.
- @REM this script is a a fusion of my 'mirror' string mirroring and $rStr random string generating macros
- @Rem Example outputs can be seen here: https://pastebin.com/807EwzCs
- @Echo off
- rem Powershell.exe -noprofile -nologo -command "Remove-item -path '%~f0' -Stream '*'"
- rem Goto:Eof
- Mode 1000
- :@================================================================================================================
- :@ Filename [<Patterns{1}> <Lines{15}> <SubLength{8}> <HorizontalRepeats{8}> <VerticalRepeats{1}>] [NoFlip{false}]
- :@ NOTE: {Int} denotes the default. Only Integer strings will be accepted for Args 1-5. Any 6th Arg disables flip
- :@ @
- :@ Arg order mandatory
- :@ Args 1-5 will only accept positive integers. Use of Args is optional, however if used:
- :@ Args will be assigned in Expected order. Missing or invalid args, including negative
- :@ or 0 integers, will be replaced with default values.
- :@ Arg 6 is optional, requires Args 1-5 to be used.
- :@ @
- :@ FileName /? : This help.
- :@ FileName /? Mirror : Mirror macro help output
- :@ FileName /? Random : $rStr macro help output
- :@ FileName /? String : $rStr macro help output
- :@ - Note:
- :@ Arguments to this script have limited interaction with macros.
- :@ @
- :@::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :@ @
- :@ Filename <filename.ext>
- :@ copy last pattern to Filename_filename.ext
- :@ @
- :@ Filename /s
- :@ Skip new pattern prompt, shows last pattern
- :@================================================================================================================
- 2> nul (
- Set /A "Patterns=%~1/1","1/Patterns" || Set /A "Patterns=1"
- Set /A "_Lines=%~2/1","1/_Lines" || Set /A "_Lines=15"
- Set /A "SubLength=%~3/1","1/Sublength" || Set /A "SubLength=8"
- Set /A "HRepeats=%~4","1/HRepeats" || Set /A "HRepeats=8"
- Set /A "VRepeats=%~5","1/VRepeats" || Set /A "VRepeats=1"
- Set /A "1/(Patterns>>9)" && Set /A "Patterns=1"
- Set /A "1/(_Lines>>9)" && Set /A "_Lines=15"
- Set /A "1/(SubLength>>9)" && Set /A "SubLength=8"
- Set /A "1/(HRepeats>>9)" && "HRepeats=8"
- Set /A "1/(VRepeats>>9)" && "VRepeats=1"
- )
- Rem dual purpose variable - header length + Arg to override Mirror macro max stringlen
- Set /A "hlen=(HRepeats*(SubLength*2))-Hrepeats"
- If "%~6"=="" (
- Set "flip= /F"
- )Else Set "flip="
- Set "Args=%*"
- If defined Args Set Args | %SystemRoot%\System32\Findstr.exe /EL "\/? -? help" > nul && (
- For /f "tokens=2* Delims=@" %%G in ('%SystemRoot%\System32\Findstr.exe /bl ":@" "%~f0"')Do (
- Set "Help=%%G"
- Cmd /Von /C "Echo(!Help: FileName= %~n0!"
- )
- Pause
- Exit /b 0
- )
- Cls & Call:DefMacros %hLen%
- If errorlevel 1 (
- Exit /b
- )
- Setlocal EnableDelayedExpansion
- Set "Divline="
- Set "Header="
- For /l %%i in (0 1 %Sublength%)Do (
- set "Divline=!Divline!="
- )
- For /l %%n in (1 1 %hlen%)Do Set "Header=!Header!="
- cls
- Rem Redirection and Errorlevel management via Call critical in respectively controlling the:
- rem output and conditional flow of the below code block
- 2> nul (%= Supress STDerr if ADS not populated =%
- More < "%~f0:Patterns.dat" > nul %!!% && (%= If ADS populated then =%
- If not "%~x1"=="" (
- Call :Skip 1>"%~dp0%~n0_%~1"
- Exit /b 0
- )
- If /I "%~1"=="/S" Goto:Skip
- If "%~2"=="" (
- Choice /M "New Pattern?"
- )Else ((Call))
- %= CTRL+C is pressed =% If !errorlevel!==0 Goto:Eof
- %= User selects No =% If !errorlevel!==2 Goto:Skip
- Cls
- %= Force +ve errorlevel =% (Call)
- )%= Else on +ve Errorlevel =% || %= Populate ADS with STDout produced in For loop. =% 1>"%~f0:Patterns.dat" (
- Title Generating Strings...
- Echo(!Header!
- 1> Con Echo(!Divline!
- For /l %%n in (1 1 %Patterns%)Do (
- Set "Str[%%n]="
- For /l %%i in (1 1 %_Lines%)Do (
- %$rStr% /l %SubLength% /P " . x {AS} ' + ~" /S 18 /V $rStr[RV]
- If defined Str[%%n] (
- Set Str[%%n]=!Str[%%n]! "!$rStr[RV]![!HRepeats!]",
- 1> Con Echo(!$rStr[RV]!^|%= Redirect STDout to console. =%
- ) Else (
- Set Str[%%n]="!$rStr[RV]![!HRepeats!]",
- 1> Con Echo(!$rStr[RV]!^|
- )
- )
- 1> Con Echo(!Divline!
- Title Combining Pattern...
- %Mirror:#=!VRepeats!% !Str[%%n]:~0,-1!!flip!
- Echo(!Header!
- (Title )
- ))
- 1> Con Pause
- )
- :Skip
- cls
- For /f Delims^= %%G in ('more ^< "%~f0:Patterns.dat"') Do Echo(%%G
- Endlocal
- @Goto:Eof
- ::====================== | Mirror MACRO Definition. Author - T3RRY | =====================
- :DefMacros
- ::| DefMirror USAGE:
- ::| *** Version changes 11/11/2021:
- ::| /F 'Flip' switch added. Mirrors pattern vertically. ! Limited to Small patterns.
- ::| *** Version changes 9/11/2021:
- ::| [Int] and {Int} partial repetition subargs may now be interchangeably positioned at string left or right.
- ::| Doublequote is now escaped with itself: "" to print " - Each paired " is substituted to `DQ` before string processing.
- ::| Multiple linefeeds may now be effected using %Mirror% "{Int}"
- ::| Usage examples and help info updated to reflect changes.
- ::|
- ::| Call :DefMirror ["/?"]|[Int]
- ::| "/?" This help info.
- ::| Int - Overrides default max string length [ Default = 50 characters per "string" ]
- ::|
- ::| Mirror Macro Usage:
- ::| %Mirror% "string" [/F]
- ::| %Mirror% "string" "otherstring" [/F]
- ::| %Mirror% "string","otherstring" [/F]
- ::| %Mirror% "string", "otherstring" [/F]
- ::| %Mirror% "string" , "otherstring" [/F]
- ::|
- ::| Whole Pattern repetition:
- ::| Repeat the whole Pattern Int number of times:
- ::| %Mirror:#=Int% "String","OtherString"
- ::|
- ::| Partial Pattern repetition:
- ::| %Mirror% "string[Int]" or "[Int]string" ; Where Int is a number [1-99]: Repeat mirrored string Int times Horizontally.
- ::| %Mirror% "string{Int}" or "{Int}string ; Where Int is a number [1-99]: Repeat mirrored string Int times Vertically.
- ::| ** Repetition features may be combined: %Mirror:#=2% "{Int}string[Int]" or %Mirror:#=2% "[Int]string{Int}"
- ::| ** Strings beginning / ending with {Int} or [Int] ALWAYS trigger this behaviour If Int is GTR 0 LSS 100.
- ::|
- ::| Additional Info:
- ::| ** Delayed expansion must NOT be enabled prior to calling DefMacros
- ::| ** Delayed expansion is toggled on/off by %Mirror% macro and is NOT REQUIRED to be enabled prior to expansion the macro.
- ::| ** Mirror macro does not require echo state to be off, and expands in it's own local environment.
- ::| - 'Reverse*CHAR' 'Flip*CHAR' '_Hash' and 'LF' variables are defined in the calling scripts environment.
- ::| ** Macro args MUST be doublequoted if multiple args are supplied, failure to doublequote will result in
- ::| the string being treated as a single arg and may cause unexpected behaviour if the string contains poison characters.
- ::| ** A temporary file is used to facilitate handling of `*` character, which cannot be handled directly in a for loop.
- ::| ** Calling :DefMirror with a MaxLength Shorter than a supplied strings length will result in the macro hanging.
- ::| ** To print a newline using the macro, The string value must contain 2 or more whitespaces: " "
- ::| To print multiple newlines: "{Int}" ; Where Int is number GTR 0 LSS 100
- ::|
- ::| Supports all ASCII Characters, Observing the following usage information and ESCAPING Requirements:
- ::| - ; Is reserved as a shading character - It will print on the left hand side of the string, and be replaced
- ::| with a whitespace on the right.
- ::| - @ is reserved for signalling the end of mirroring. Text following @ is printed between mirrored text.
- ::| to use @ literally, escape it with itself: @@ [note: doing so will result in all text following @@ being mirrored.]
- ::| - To print a doublequote, escape it with itself: "str""ing" will print: str"inggni"rts
- ::| - ! must be triple escaped: ^^^!
- ::| - /F Switch is incompatable with !, even when escaped.
- ::| - Any string containing ^^^! will require literal carets to also be triple escaped:
- ::| IE: "^^^^Hello, World^^^! " to print: "^Hello, World! !dlroW ,olleH^"
- ::| - % must be escaped: %%
- ::|
- ::========================================================================================
- @If "!!"=="" @(Echo(Delayed expansion not permitted prior to macro definition.& @Pause & @Exit/b 1)
- @If defined Args (
- @Set Args | %SystemRoot%\System32\Findstr.exe /elic:"Mirror" > nul && @(
- %SystemRoot%\System32\Findstr.exe /blic:"::" "%~f0" | more
- Exit /b 1
- )
- Set Args | %SystemRoot%\System32\Findstr.exe /eli "Random String" > nul && @(
- %SystemRoot%\System32\Findstr.exe /blic:":#" "%~f0" | more
- Exit /b 1
- )
- )
- @Set "_Hash=#"
- @(Set LF=^
- %= LF Linefeed variable Used in macro. Do not Modify. =%)
- @(Set \n=^^^
- %= \n Newline variable for macro definition. Do not Modify =%)
- @For %%G in ("(=)" ")=(" "[=]" "]=[" "{=}" "}={" "/=\" "\=/")Do @Set "Replace%%~G"
- @For %%G in ("M=W" "W=M" "6=9" "9=6" "v=^" "^=v" "`=." ".=`")Do @Set "Flip%%~G"
- @Set "Flip'=,"
- @Set "Flip,='"
- @Set "_EX=^!"
- @Set "Replace>=<"
- @Set "Replace<=>"
- @Setlocal
- @Set "MaxLen=0"
- @For %%G in (%*)Do @Set/A "MaxLen=%%~G" 2> nul || @Set "MaxLen=50"
- @If %MaxLen% LEQ 0 @Set "MaxLen=50"
- @Endlocal & @Set Mirror=@For %%v in (1 2)Do @if %%v==2 (%\n%
- @If Defined Mirror.Input (%\n%
- @Set "[F]="%\n%
- @If /I "!Mirror.Input:~-3!"==" /F" @(%\n%
- @Set "Mirror.Input=!Mirror.Input:~0,-3!"%\n%
- @Set "[F]=true"%\n%
- )%\n%
- @Set "#="%\n: Undefined in local environment to ensure no false positives below =%
- @If not "!_Hash!"=="#" @(Set /A "1 / #" 2^> nul ^&^& (@Set /A "_Repeat=#") ^|^| @Set "_Repeat=1")Else @Set _Repeat=1%\n%
- @For /l %%T in (1 1 !_Repeat!)Do @(%\n: Repeat entire pattern from args list. For loop input will repeated each input. =%
- @Set "_F="%\n%
- @Set "Mirror.Input=!Mirror.Input:*"="!"%\n: Strip leading characters that precede first doublequote =%
- @Set "Mirror.Input=!Mirror.Input:""=`DQ`!"%\n: Enact temp Substitution of Escaped Doublequotes =%
- @For %%G in ("!LF!")Do @(%\n: Delim args with a newline prior to outputting to file. =%
- @Set "Mirror.Input=!Mirror.Input:" , "=%%G!"%\n%
- @Set "Mirror.Input=!Mirror.Input:", "=%%G!"%\n%
- @Set "Mirror.Input=!Mirror.Input:","=%%G!"%\n%
- @Set "Mirror.Input=!Mirror.Input:" "=%%G!"%\n%
- )%\n%
- ^>"%~dpn0_In.~tmp" (Echo(!Mirror.Input!)%\n: Output prepared args to allow processing of all ASCII characters. =%
- @For /f "usebackq Delims=" %%G in ("%~dpn0_In.~tmp")Do @(%\n: Read and process args line by line =%
- @Set "_P="%\n: nul var used to Flag escaping of @ character =%
- @Set "_S="%\n: nul Arg output var =%
- @Set "_V=%%~G"%\n: Define Arg string =%
- @Set/A"_Y=_X=1"%\n: Define default Horizontal and vertical Arg repeat counts =%
- @Set ^"_V=!_V:"=!"%\n: Strip Doublequotes from Arg =%
- @Rem %\n: Begin Assessment and flagging of [Int] X {Int} Y Partial repetition subargs =%
- @Set /A 1 / !_V:~1,1! 2^> nul ^&^& @If "!_V:~0,1!!_V:~2,1!"=="{}" (%\n%
- @Set "_Y=!_V:~1,1!"%\n%
- @Set "_V=!_V:~3,%MaxLen%!"%\n%
- )Else @If "!_V:~0,1!!_V:~2,1!"=="[]" (%\n%
- @Set "_X=!_V:~-1,1!"%\n%
- @Set "_V=!_V:~1,1!"%\n%
- )%\n%
- @Set /A 1 / !_V:~1,2! 2^> nul ^&^& @If "!_V:~0,1!!_V:~3,1!"=="{}" (%\n%
- @Set "_Y=!_V:~1,2!"%\n%
- @Set "_V=!_V:~4,%MaxLen%!"%\n%
- )Else @If "!_V:~0,1!!_V:~3,1!"=="[]" (%\n%
- @Set "_X=!_V:~1,2!"%\n%
- @Set "_V=!_V:~4,%MaxLen%!"%\n%
- )%\n%
- @Set /A 1 / !_V:~-2,1! 2^> nul ^&^& @If "!_V:~-3,1!!_V:~-1!"=="[]" (%\n%
- @Set "_X=!_V:~-2,1!"%\n%
- @Set "_V=!_V:~0,-3!"%\n%
- )Else @If "!_V:~-3,1!!_V:~-1!"=="{}" (%\n%
- @Set "_Y=!_V:~-2,1!"%\n%
- @Set "_V=!_V:~0,-3!"%\n%
- )%\n%
- @Set /A 1 / !_V:~-3,2! 2^> nul ^&^& @If "!_V:~-4,1!!_V:~-1!"=="[]" (%\n%
- @Set "_X=!_V:~-3,2!"%\n%
- @Set "_V=!_V:~0,-4!"%\n%
- )Else @If "!_V:~-4,1!!_V:~-1!"=="{}" (%\n%
- @Set "_Y=!_V:~-3,2!"%\n%
- @Set "_V=!_V:~0,-4!"%\n%
- )%\n: Next Line enacts escaping of @@ or splitting of Mirror / nonmirrored substrings =%
- @If "!_V:@@=!"=="!_V!" (@For /f "tokens=1,2 Delims=@" %%G in ("!_V!")Do @Set "_V=%%~G"^&@set "_P=%%~H")Else @If defined _V @set "_V=!_V:@@=@!"%\n%
- @If defined _V @Set ^"_V=!_V:`DQ`="!"%\n: enacts substitution to reinsert doublequotes =%
- @Set "_I="%\n: nul string length variables =%
- @Set "_Pi="%\n: Next line gets full string length =%
- @For /l %%i in (0 1 %MaxLen%)Do @If not defined _I @If "!_V:~%%i!"=="" @Set/A"_I=%%i,_O=%%i-2" 2^> nul%\n%
- @If defined _P (%\n: Get offset length if @ used to split substring =%
- @For /l %%i in (0 1 %MaxLen%)Do @If not defined _Pi @If "!_P:~%%i!"=="" @Set/A"_Pi=%%i"%\n%
- @Set /A _O=_Pi-_O%\n%
- )%\n%
- @If Defined _V @For /l %%i in (0 1 !_I!)Do @Set "_S=!_S!!_V:~%%i,1!"%\n: Build Left half of output string =%
- @Set "_S=!_S!!_P!"%\n: Append unmirrored component if defined =%
- @For /l %%i in (!_O! -1 0)Do @(%\n: Append mirror of string enacting replacements =%
- @If "!_V:~%%i,1!"==";" @Set "_S=!_S! "%\n%
- @For /f "delims=" %%v in ("!_V:~%%i,1!")Do @(If not "!Replace%%v!"=="" @(Set "_S=!_S!!Replace%%v!")Else @Set "_S=!_S!!_V:~%%i,1!")%\n%
- )%\n%
- @Set "_M="%\n: nul _M var used to join horizontal repetitions =%
- @For /l %%i in (1 1 !_X!)Do @Set "_M=!_M!!_S!"%\n: append horizontal repetitions =%
- @If Defined _M @Set "_S=!_M!"%\n: Swap out appended string if defined =%
- @Set "_Fc="%\n%
- @If Defined [F] @For /l %%i in (0 1 %MaxLen%)Do @If not "!_S:~%%i,1!"=="" @(%\n: define vertical mirror of substring enacting replacements =%
- @For /f "delims=" %%v in ("!_S:~%%i,1!")Do @(If not "!Replace%%v!"=="" @(Set "_Fc=!_Fc!!Replace%%v!")Else @If not "!Flip%%v!"=="" @(Set "_Fc=!_Fc!!Flip%%v!")Else (@Set "_Fc=!_Fc!!_S:~%%i,1!"))%\n%
- )%\n%
- @For /l %%i in (1 1 !_Y!)Do @(%\n%
- @Echo(!_S!%\n: repeat string vertically =%
- )%\n%
- @If Defined [F] @(@If not Defined _F @(@Set "_F=!_Fc!")Else @Set "_F=!_Fc!!LF!!_F!")%\n: Append vertical Mirror =%
- )%\n%
- @If Defined [F] @Echo(!_F!%\n%
- @Del "%~dpn0_In.~tmp" 2^> nul%\n%
- )%\n: remove the temp file used. =%
- @Endlocal%\n: Ends the local environment if args supplied. =%
- )Else @Endlocal%\n: Ends the local environment if no args supplied to macro. =%
- )Else @Setlocal ENableDelayedExpansion ^& @Set Mirror.Input=
- :#====================== | $rStr MACRO Definition. Author - T3RRY | =====================
- :!!| $rStr Args: Description:
- :!!|
- :!!| /L Int : Length of each Substring [MANDATORY] - At least one length must be supplied.
- :!!| /L Int Int Int : Varying Lengths may be provided for each Substring
- :!!| by supplying the length for the corresponding iteration.
- :!!| /R Iterations is defined as the number of lengths provided.
- :!!| /Mod Int IntSum : Supply a Range for a Random Length at provided Index.
- :!!| - Example: Two part string Part 1 = 5 characters, Part 2 = 7-15 characters:
- :!!| /L 5 . /Mod :0 9+7 /D :
- :!!| - OVERIDES /L 5 . TO /L 5 [RandomInt 7-15]
- :!!| * Modifier value should be at same index of /Mod SubArgs as '.' is in /L:SubArgs
- :!!| - Use 0 values for Modifier list to retain /L lengths at original index.
- :!!|
- :!!| /Rep Int : Number of Iterations to repeat pattern as an Integer
- :!!| - Use /Rep when all Iterations of pattern are to be same /L length
- :!!|
- :!!| /V ReturnVar : Define Supplied returnvar with generated String
- :!!| - If no return var is supplied, value will be stored in $rStr_RV
- :!!|
- :!!| /A ReturnVar : Append generated string to supplied return variable.
- :!!|
- :!!| /P Pattern Subargs:
- :!!| - Predefined : ANM - English Letters in Upper and Lower case + 0~9 [ DEFAULT ]
- :!!| : ANL - English Letters in Lower case + 0~9
- :!!| : ANU - English Letters in Upper case + 0~9
- :!!| : AL - English Letters in Lower case
- :!!| : AU - English Letters in Upper case
- :!!| : N - 0~9
- :!!| : H - Hex String: ABCDEF0123456789
- :!!|
- :!!| - Range : Character Range - Provide a range to use as the Character Set.
- :!!| - Example: /P [3-w] = 3456789abcdefghijklmnopqrstuvw
- :!!| - Range Order: 0-9a-zA-Z ; Total Available Range: 0-Z
- :!!|
- :!!| - Custom : "Character String"
- :!!| - provide a custom string of characters to use. Example:
- :!!| /L 3 3 /P "-+@$^&()" /S 6 /D -
- :!!|
- :!!| /S Int : Supply the length of a Custom Pattern.
- :!!|
- :!!| /D "Delim" : Delim Character to use.
- :!!| /D "Delim Delim" : Supply Multiple Delims ; inserted after each corresponding iteration.
- :!!| Delim Substitution: The following characters require substitution to use:
- :!!| - {FS} for / Forward-Slash ; {SC} for ; Semicolon
- :!!| - {AS} for * Asterisk ; {CM} for , Comma
- :!!| - {EQ} for = Equals
- :!!|
- :!!| /B "Delim Delim" : Bookend the string with the supplied pair of Delims.
- :!!|
- :!!| /O : Output the Generated string to STDOUT
- :!!|
- :#========================================================================================
- Rem $rStr Switches. Defined outside macro for readability and maintainance.
- Set $rStr[Switches]="V" "A" "P" "L" "S" "R" "D" "O" "Mod" "B" "Rep"
- Set $rStr=For %%n in (1 2)Do if %%n==2 ( %\n: CAPTURE ARG STRING =%
- Set "$rStr[Syntax]=%\E%[33m!$rStr[args]!"%\n%
- For /F "Tokens=1,2 Delims==" %%G in ('Set "$rStr_" 2^^^> nul')Do Set "%%~G=" %\n: RESETS ALL MACRO INTERNAL VARS =%
- If not "!$rStr[args]:* /=!" == "!$rStr[args]!" ( %\n: BUILD $rStr.Args[!$rStr_arg[i]!] ARRAY IF ARGS PRESENT =%
- Set "$rStr_leading.args=!$rStr[args]:*/=!" %\n: SPLIT ARGS FROM SWITCHES =%
- For /F "Delims=" %%G in ("!$rStr_leading.args!")Do Set "$rStr_leading.args=!$rStr[args]:/%%G=!"%\n%
- Set ^"$rStr[args]=!$rStr[args]:"=!" %\n: REMOVE DOUBLEQUOTES FROM REMAINING ARGSTRING - SWITCHES =%
- Set "$rStr_arg[i]=0" %\n: ZERO INDEX FOR ARGS ARRAY =%
- For %%G in (!$rStr_leading.args!)Do ( %\n: BUILD ARGS ARRAY =%
- Set /A "$rStr_arg[i]+=1"%\n%
- Set "$rStr_arg[!$rStr_arg[i]!]=%%~G"%\n%
- For %%i in ("!$rStr_arg[i]!")Do ( %\n: SUBSTITUTE THE FOLLOWING POISON CHARACTERS =%
- Set "$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{SC}=;!"%\n%
- Set "$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{QM}=?!"%\n%
- Set "$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{FS}=/!"%\n%
- Set "$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{AS}=*!"%\n%
- Set "$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{EQ}==!"%\n%
- Set ^"$rStr_arg[%%~i]=!$rStr_arg[%%~i]:{DQ}="!"%\n%
- ))) Else ( %\n: IF NO ARGS REMOVE DOUBLEQUOTES FROM ARGSTRING - SWITCHES =%
- Set ^"$rStr[args]=!$rStr[args]:"=!"%\n%
- Set "$rStr_Arg[1]=!$rStr[args]!"%\n%
- Set "$rStr_Arg[i]=1"%\n%
- )%\n%
- For /L %%L in (2 1 4)Do If "!$rStr_LastSwitch!" == "" (%\n%
- If "!$rStr[args]:~-%%L,1!" == " " Set "$rStr_LastSwitch=_"%\n%
- If "!$rStr[args]:~-%%L,1!" == "/" ( %\n: FLAG LAST SWITCH TRUE IF NO SUBARGS ; FOR SWITCHES UP TO 3 CHARCTERS LONG =%
- For /F "Delims=" %%v in ('Set /A "%%L-1"')Do Set "$rStr_Switch[!$rStr[args]:~-%%v!]=true"%\n%
- Set "$rStr[args]=!$rStr[args]:~0,-%%L!"%\n%
- Set "$rStr_LastSwitch=_"%\n%
- )%\n%
- )%\n%
- For %%G in ( %$rStr[Switches]% )Do If not "!$rStr[args]:/%%~G =!" == "!$rStr[args]!" (%\n: SPLIT AND ASSIGN SWITCH VALUES =%
- Set "$rStr_Switch[%%~G]=!$rStr[args]:*/%%~G =!"%\n%
- If not "!$rStr_Switch[%%~G]:*/=!" == "!$rStr_Switch[%%~G]!" (%\n%
- Set "$rStr_Trail[%%~G]=!$rStr_Switch[%%~G]:*/=!"%\n%
- For %%v in ("!$rStr_Trail[%%~G]!")Do (%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]: /%%~v=!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:/%%~v=!"%\n%
- )%\n%
- Set "$rStr_Trail[%%~G]="%\n%
- If "!$rStr_Switch[%%~G]:~-1!" == " " Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:~0,-1!"%\n%
- If "!$rStr_Switch[%%~G]!" == "" Set "$rStr_Switch[%%~G]=true"%\n%
- If not "!$rStr_Switch[%%~G]!" == "" If not "!$rStr_Switch[%%~G]!" == "true" (%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:{SC}=;!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:{QM}=?!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:{FS}=/!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:{AS}=*!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:{EQ}==!"%\n%
- Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]!"%\n%
- ))%\n%
- If "!$rStr_Switch[%%~G]:~-1!" == " " Set "$rStr_Switch[%%~G]=!$rStr_Switch[%%~G]:~0,-1!"%\n%
- Set "$rStr[RV]="%\n%
- )%\n: ACTION SWITCH ASSESSMENT BELOW. USE CONDITIONAL TESTING OF VALID SWITCHES OR ARGS ARRAY TO ENACT COMMANDS FOR YOUR MACRO FUNCTION =%
- Set "$rStr_Var=$Rstr_RV"%\n%
- If not "!$rStr_Switch[L]!" == "true" If not "!$rStr_Switch[L]!" == "" (%\n%
- For %%G in ( Switch[L] Switch[B] Switch[D] Switch[Mod] )Do If not "!$rStr_%%G!" == "true" If not "!$rStr_%%G!" == "" (%\n%
- Set "$rStr_%%G[i]=0"%\n%
- For %%H in (!$rStr_%%G!)Do (%\n%
- Set /A "$rStr_%%G[i]+=1"%\n%
- Set "$rStr_%%G[!$rStr_%%G[i]!]=%%H"%\n%
- For %%q in (Switch[B] Switch[D])Do if "%%q" == "%%G" (%\n%
- Set "rStr_dSub=%%H"%\n%
- Set "rStr_dSub=!rStr_dSub:{AS}=*!"%\n%
- Set "rStr_dSub=!rStr_dSub:{SC}=;!"%\n%
- Set "rStr_dSub=!rStr_dSub:{CN}=:!"%\n%
- Set "rStr_dSub=!rStr_dSub:{CM}=,!"%\n%
- Set "$rStr_%%G[!$rStr_%%G[i]!]=!rStr_dSub!"%\n%
- )%\n%
- If "%%G" == "Switch[Mod]" If not "%%H" == "0" Set /A "$rStr_Switch[L][!$rStr_%%G[i]!]=!random! %% %%H "%\n%
- ))%\n%
- If "!$rStr_Switch[P]!" == "" Set "$rStr_Switch[P]=ANM" %\n%
- If "!$rStr_Switch[P]!" == "true" Set "$rStr_Switch[P]=ANM" %\n%
- If /I "!$rStr_Switch[P]!" == "ANM" ( Set "$rStr_CharSet=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ^& Set "$rStr_pSize=62" )%\n%
- If /I "!$rStr_Switch[P]!" == "ANU" ( Set "$rStr_CharSet=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ^& Set "$rStr_pSize=36" )%\n%
- If /I "!$rStr_Switch[P]!" == "ANL" ( Set "$rStr_CharSet=abcdefghijklmnopqrstuvwxyz0123456789" ^& Set "$rStr_pSize=36" )%\n%
- If /I "!$rStr_Switch[P]!" == "AM" ( Set "$rStr_CharSet=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ^& Set "$rStr_pSize=52" )%\n%
- If /I "!$rStr_Switch[P]!" == "AL" ( Set "$rStr_CharSet=abcdefghijklmnopqrstuvwxyz" ^& Set "$rStr_pSize=26" )%\n%
- If /I "!$rStr_Switch[P]!" == "AU" ( Set "$rStr_CharSet=ABCDEFGHIJKLMNOPQRSTUVWXYZ" ^& Set "$rStr_pSize=26" )%\n%
- If /I "!$rStr_Switch[P]!" == "N" ( Set "$rStr_CharSet=1234567890" ^& Set "$rStr_pSize=10" )%\n%
- If /I "!$rStr_Switch[P]!" == "H" ( Set "$rStr_CharSet=ABCDEF0123456789" ^& Set "$rStr_pSize=16" )%\n%
- If not "!$rStr_Switch[P]:*]=!." == "!$rStr_Switch[P]!." (%\n: facilitate custom P [start-end] Pattern Range =%
- For /F "Tokens=1,2 Delims=[-]" %%1 in ("!$rStr_Switch[P]!")Do (%\n%
- Set "$rStr_pSize="^& Set "$rStr_Start=%%1"%\n%
- For %%c in ( 0 1 2 3 4 5 6 7 8 9 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 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 (%\n%
- If "%%c" == "%%1" (%\n%
- Set "$rStr_CharSet=%%c"%\n%
- Set "$rStr_pSize=0"%\n%
- )%\n%
- If "%%c" == "%%2" (%\n%
- Set "$rStr_CharSet=!$rStr_CharSet!%%c"%\n%
- Set "$rStr_Start="%\n%
- Set /A "$rStr_pSize+=1"%\n%
- )%\n%
- If not "!$rStr_CharSet!" == "%%c" If not "!$rStr_Start!" == "" (%\n%
- Set "$rStr_CharSet=!$rStr_CharSet!%%c"%\n%
- Set /A "$rStr_pSize+=1"%\n%
- ))))%\n%
- If "!$rStr_CharSet!" == "" (%\n%
- Set "$rStr_CharSet=!$rStr_Switch[P]!"%\n%
- If not "!$rStr_Switch[S]!" == "" If not "!$rStr_Switch[S]!" == "true" (Set "$rStr_pSize=!$rStr_Switch[S]!")%\n%
- If "!$rStr_pSize!" == "" (%\n%
- For /L %%i in (0 1 200) Do If "!$rStr_pSize!" == "" If "!$rStr_Switch[P]:~%%i,1!" == "" ( Set /A "$rStr_pSize=%%i-1" )%\n%
- ))%\n%
- If "!$rStr_Switch[R]!" == "" Set "$rStr_Switch[R]=!$rStr_Switch[L][i]!"%\n%
- If not "!$rStr_Switch[Rep]!" == "" (%\n%
- Set "$rStr_Switch[D]=!$rStr_Switch[D]:{SC}=;!"%\n%
- Set "$rStr_Switch[D]=!$rStr_Switch[D]:{CM}=,!"%\n%
- Set "$rStr_Switch[D]=!$rStr_Switch[D]:{AS}=*!"%\n%
- Set "$rStr_Switch[R]=!$rStr_Switch[Rep]!"%\n%
- For /L %%i in (1 1 !$rStr_Switch[R]!)Do (%\n%
- Set "$rStr_Switch[L][%%i]=!$rStr_Switch[L]!"%\n%
- Set "$rStr_Switch[D][%%i]=!$rStr_Switch[D]!"%\n%
- If "%%i" == "!$rStr_Switch[Rep]!" Set "$rStr_Switch[D][%%i]="%\n%
- ))%\n%
- For /L %%i in (1 1 !$rStr_Switch[R]!) Do (%\n%
- FOR /L %%n IN (1 1 !$rStr_Switch[L][%%i]!)Do (%\n%
- For /F "delims=" %%c In ( 'SET /A "!RANDOM! %% !$rStr_pSize!"' )Do (%\n%
- Set "$rStr[RV]=!$rStr[RV]!!$rStr_CharSet:~%%c,1!"%\n%
- ))%\n%
- Set "$rStr[RV]=!$rStr[RV]!!$rStr_Switch[D][%%i]!"%\n%
- )%\n%
- Set "$rStr[RV]=!$rStr_Switch[B][1]!!$rStr[RV]!!$rStr_Switch[B][2]!"%\n%
- If not "!$rStr_Switch[A]!" == "" ( Set "$rStr_Var=!$rStr_Switch[A]!" ^& For /F "Delims=" %%v in ("!$rStr_Switch[A]!")Do Set "$rStr[RV]=!%%v!!$rStr[RV]!")%\n%
- If not "!$rStr_Switch[V]!" == "" ( Set "$rStr_Var=!$rStr_Switch[V]!" ^& Set "!$rStr_Switch[V]!=!$rStr[RV]!" 2^> nul) %\n%
- If "!$rStr_Switch[O]!" == "true" Echo(!$rStr[RV]!%\n%
- )Else (Echo( /L Integer Required^^! )%\n%
- ) Else Set $rStr[args]=
- Exit /b 0
Add Comment
Please, Sign In to add comment