Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- REM example
- SETLOCAL
- Set "String[1]=Some !@#$%%^& string"
- If not "%~1"=="" Set "String[1]=%~1"
- Call:Mixer String[1] String[2]
- Set String
- Pause
- ENDLOCAL & Goto:Eof
- :Mixer <SourceVariable> <ReturnVariable>
- Setlocal DISABLEdelayedexpansion
- If "%~2" == "" Exit /b 2
- If "%~1" == "" Exit /b 1
- For /f "tokens=1 delims==" %%G in ('Set Char[ 2^> nul') Do Set "%%G="
- For /f "UsebackQ tokens=1,2 Delims=:" %%G in (`cmd /V:On /u /c ^"^<nul set/p "=!%~1!"^"^| find /v "" ^| findstr /n "^"`)Do (
- Set "Char[%%G]=%%H"
- Set "Count=%%G"
- )
- Set "string="
- Setlocal EnableDelayedexpansion
- %= For each in reducing array =% For /l %%i in (%Count% -1 1)Do (
- %= Select random index to =% Set /A {Random_Index}=!Random! %% %%i + 1
- %= expand from =% For %%r in (!{Random_Index}!)Do (
- %= Append Char @index 2 string =% Set "String=!String!!Char[%%r]!"
- %= Swap char at last index to =% Set "Char[%%r]=!Char[%%i]!"
- %= selected index # =% ) )
- (
- Endlocal & Endlocal & 2> nul Set "%~2=%String%"
- Exit /B 0
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement