Bat file that can create a text file of any exact size and it will be compression resistant

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite
1












I'm making a bat file that can create a text file of any exact size and it will be compression resistant just for fun. It's currently in 2 parts because that's the only way I could figure out how to do it. I tried running the second part in a loop in the first one so I didn't need to use the call command but it didn't work.



The problem is that it takes forever and my CPU peaks at 31% so I'm wondering if there is a way to make it use the CPU more so it can execute faster or just make my code more efficient so it runs faster.



This is part one:



@set GB=1
@set TB=0
@set PB=0
@set /a "g=1*%GB%"
@set /a "t=1024*%TB%"
@set /a "p=1048576*%PB%"
@set /a "Total=%g%+%t%+%p%"
@set /a "c=%Total%*262144"
@set /a "d=%c%-1"
@echo on
@set /a "gTotal=%Total%/1"
echo %gTotal% GB
@set /a "tTotal=%gTotal%/1024"
echo %tTotal% TB
@set /a "pTotal=%tTotal%/1024"
echo %pTotal% PB
echo to create %gTotal%GB_RandPass.txt press any key
pause
@Echo Off
color 0a
::set /P lengthnumberuser="What length do you want your password to be? "
::pause
::cls
Setlocal EnableDelayedExpansion
Set _RNDLength=4101
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop
Echo Password is: is !_RndAlphaNum!
::pause
@echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
for /l %%x in (1, 1, %d%) do (
call "create_1GB-2EB_fileV4_Part2.bat"
)
:: @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
::)


This is part 2:



@set GB=1
@set TB=0
@set PB=0
@set /a "g=1*%GB%"
@set /a "t=1024*%TB%"
@set /a "p=1048576*%PB%"
@set /a "Total=%g%+%t%+%p%"
@set /a "c=%Total%*262144"
@set /a "d=%c%-1"
::@echo on
@set /a "gTotal=%Total%/1"
::echo %gTotal% GB
@set /a "tTotal=%gTotal%/1024"
::echo %tTotal% TB
@set /a "pTotal=%tTotal%/1024"
::echo %pTotal% PB
echo createing %gTotal%GB_RandPass.txt Please wait.
::pause
@Echo Off
color 0a
::set /P lengthnumberuser="What length do you want your password to be? "
::pause
::cls
Setlocal EnableDelayedExpansion
Set _RNDLength=4101
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop
Echo Password is: is !_RndAlphaNum!
::pause
::@echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
::for /l %%x in (1, 1, %d%) do (
@echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
::)






share|improve this question



























    up vote
    1
    down vote

    favorite
    1












    I'm making a bat file that can create a text file of any exact size and it will be compression resistant just for fun. It's currently in 2 parts because that's the only way I could figure out how to do it. I tried running the second part in a loop in the first one so I didn't need to use the call command but it didn't work.



    The problem is that it takes forever and my CPU peaks at 31% so I'm wondering if there is a way to make it use the CPU more so it can execute faster or just make my code more efficient so it runs faster.



    This is part one:



    @set GB=1
    @set TB=0
    @set PB=0
    @set /a "g=1*%GB%"
    @set /a "t=1024*%TB%"
    @set /a "p=1048576*%PB%"
    @set /a "Total=%g%+%t%+%p%"
    @set /a "c=%Total%*262144"
    @set /a "d=%c%-1"
    @echo on
    @set /a "gTotal=%Total%/1"
    echo %gTotal% GB
    @set /a "tTotal=%gTotal%/1024"
    echo %tTotal% TB
    @set /a "pTotal=%tTotal%/1024"
    echo %pTotal% PB
    echo to create %gTotal%GB_RandPass.txt press any key
    pause
    @Echo Off
    color 0a
    ::set /P lengthnumberuser="What length do you want your password to be? "
    ::pause
    ::cls
    Setlocal EnableDelayedExpansion
    Set _RNDLength=4101
    Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
    Set _Str=%_Alphanumeric%987654321
    :_LenLoop
    IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
    SET _tmp=%_Str:~9,1%
    SET /A _Len=_Len+_tmp
    Set _count=0
    SET _RndAlphaNum=
    :_loop
    Set /a _count+=1
    SET _RND=%Random%
    Set /A _RND=_RND%%%_Len%
    SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
    If !_count! lss %_RNDLength% goto _loop
    Echo Password is: is !_RndAlphaNum!
    ::pause
    @echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
    for /l %%x in (1, 1, %d%) do (
    call "create_1GB-2EB_fileV4_Part2.bat"
    )
    :: @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
    ::)


    This is part 2:



    @set GB=1
    @set TB=0
    @set PB=0
    @set /a "g=1*%GB%"
    @set /a "t=1024*%TB%"
    @set /a "p=1048576*%PB%"
    @set /a "Total=%g%+%t%+%p%"
    @set /a "c=%Total%*262144"
    @set /a "d=%c%-1"
    ::@echo on
    @set /a "gTotal=%Total%/1"
    ::echo %gTotal% GB
    @set /a "tTotal=%gTotal%/1024"
    ::echo %tTotal% TB
    @set /a "pTotal=%tTotal%/1024"
    ::echo %pTotal% PB
    echo createing %gTotal%GB_RandPass.txt Please wait.
    ::pause
    @Echo Off
    color 0a
    ::set /P lengthnumberuser="What length do you want your password to be? "
    ::pause
    ::cls
    Setlocal EnableDelayedExpansion
    Set _RNDLength=4101
    Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
    Set _Str=%_Alphanumeric%987654321
    :_LenLoop
    IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
    SET _tmp=%_Str:~9,1%
    SET /A _Len=_Len+_tmp
    Set _count=0
    SET _RndAlphaNum=
    :_loop
    Set /a _count+=1
    SET _RND=%Random%
    Set /A _RND=_RND%%%_Len%
    SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
    If !_count! lss %_RNDLength% goto _loop
    Echo Password is: is !_RndAlphaNum!
    ::pause
    ::@echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
    ::for /l %%x in (1, 1, %d%) do (
    @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
    ::)






    share|improve this question























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      I'm making a bat file that can create a text file of any exact size and it will be compression resistant just for fun. It's currently in 2 parts because that's the only way I could figure out how to do it. I tried running the second part in a loop in the first one so I didn't need to use the call command but it didn't work.



      The problem is that it takes forever and my CPU peaks at 31% so I'm wondering if there is a way to make it use the CPU more so it can execute faster or just make my code more efficient so it runs faster.



      This is part one:



      @set GB=1
      @set TB=0
      @set PB=0
      @set /a "g=1*%GB%"
      @set /a "t=1024*%TB%"
      @set /a "p=1048576*%PB%"
      @set /a "Total=%g%+%t%+%p%"
      @set /a "c=%Total%*262144"
      @set /a "d=%c%-1"
      @echo on
      @set /a "gTotal=%Total%/1"
      echo %gTotal% GB
      @set /a "tTotal=%gTotal%/1024"
      echo %tTotal% TB
      @set /a "pTotal=%tTotal%/1024"
      echo %pTotal% PB
      echo to create %gTotal%GB_RandPass.txt press any key
      pause
      @Echo Off
      color 0a
      ::set /P lengthnumberuser="What length do you want your password to be? "
      ::pause
      ::cls
      Setlocal EnableDelayedExpansion
      Set _RNDLength=4101
      Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
      Set _Str=%_Alphanumeric%987654321
      :_LenLoop
      IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
      SET _tmp=%_Str:~9,1%
      SET /A _Len=_Len+_tmp
      Set _count=0
      SET _RndAlphaNum=
      :_loop
      Set /a _count+=1
      SET _RND=%Random%
      Set /A _RND=_RND%%%_Len%
      SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
      If !_count! lss %_RNDLength% goto _loop
      Echo Password is: is !_RndAlphaNum!
      ::pause
      @echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
      for /l %%x in (1, 1, %d%) do (
      call "create_1GB-2EB_fileV4_Part2.bat"
      )
      :: @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
      ::)


      This is part 2:



      @set GB=1
      @set TB=0
      @set PB=0
      @set /a "g=1*%GB%"
      @set /a "t=1024*%TB%"
      @set /a "p=1048576*%PB%"
      @set /a "Total=%g%+%t%+%p%"
      @set /a "c=%Total%*262144"
      @set /a "d=%c%-1"
      ::@echo on
      @set /a "gTotal=%Total%/1"
      ::echo %gTotal% GB
      @set /a "tTotal=%gTotal%/1024"
      ::echo %tTotal% TB
      @set /a "pTotal=%tTotal%/1024"
      ::echo %pTotal% PB
      echo createing %gTotal%GB_RandPass.txt Please wait.
      ::pause
      @Echo Off
      color 0a
      ::set /P lengthnumberuser="What length do you want your password to be? "
      ::pause
      ::cls
      Setlocal EnableDelayedExpansion
      Set _RNDLength=4101
      Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
      Set _Str=%_Alphanumeric%987654321
      :_LenLoop
      IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
      SET _tmp=%_Str:~9,1%
      SET /A _Len=_Len+_tmp
      Set _count=0
      SET _RndAlphaNum=
      :_loop
      Set /a _count+=1
      SET _RND=%Random%
      Set /A _RND=_RND%%%_Len%
      SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
      If !_count! lss %_RNDLength% goto _loop
      Echo Password is: is !_RndAlphaNum!
      ::pause
      ::@echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
      ::for /l %%x in (1, 1, %d%) do (
      @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
      ::)






      share|improve this question













      I'm making a bat file that can create a text file of any exact size and it will be compression resistant just for fun. It's currently in 2 parts because that's the only way I could figure out how to do it. I tried running the second part in a loop in the first one so I didn't need to use the call command but it didn't work.



      The problem is that it takes forever and my CPU peaks at 31% so I'm wondering if there is a way to make it use the CPU more so it can execute faster or just make my code more efficient so it runs faster.



      This is part one:



      @set GB=1
      @set TB=0
      @set PB=0
      @set /a "g=1*%GB%"
      @set /a "t=1024*%TB%"
      @set /a "p=1048576*%PB%"
      @set /a "Total=%g%+%t%+%p%"
      @set /a "c=%Total%*262144"
      @set /a "d=%c%-1"
      @echo on
      @set /a "gTotal=%Total%/1"
      echo %gTotal% GB
      @set /a "tTotal=%gTotal%/1024"
      echo %tTotal% TB
      @set /a "pTotal=%tTotal%/1024"
      echo %pTotal% PB
      echo to create %gTotal%GB_RandPass.txt press any key
      pause
      @Echo Off
      color 0a
      ::set /P lengthnumberuser="What length do you want your password to be? "
      ::pause
      ::cls
      Setlocal EnableDelayedExpansion
      Set _RNDLength=4101
      Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
      Set _Str=%_Alphanumeric%987654321
      :_LenLoop
      IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
      SET _tmp=%_Str:~9,1%
      SET /A _Len=_Len+_tmp
      Set _count=0
      SET _RndAlphaNum=
      :_loop
      Set /a _count+=1
      SET _RND=%Random%
      Set /A _RND=_RND%%%_Len%
      SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
      If !_count! lss %_RNDLength% goto _loop
      Echo Password is: is !_RndAlphaNum!
      ::pause
      @echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
      for /l %%x in (1, 1, %d%) do (
      call "create_1GB-2EB_fileV4_Part2.bat"
      )
      :: @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
      ::)


      This is part 2:



      @set GB=1
      @set TB=0
      @set PB=0
      @set /a "g=1*%GB%"
      @set /a "t=1024*%TB%"
      @set /a "p=1048576*%PB%"
      @set /a "Total=%g%+%t%+%p%"
      @set /a "c=%Total%*262144"
      @set /a "d=%c%-1"
      ::@echo on
      @set /a "gTotal=%Total%/1"
      ::echo %gTotal% GB
      @set /a "tTotal=%gTotal%/1024"
      ::echo %tTotal% TB
      @set /a "pTotal=%tTotal%/1024"
      ::echo %pTotal% PB
      echo createing %gTotal%GB_RandPass.txt Please wait.
      ::pause
      @Echo Off
      color 0a
      ::set /P lengthnumberuser="What length do you want your password to be? "
      ::pause
      ::cls
      Setlocal EnableDelayedExpansion
      Set _RNDLength=4101
      Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
      Set _Str=%_Alphanumeric%987654321
      :_LenLoop
      IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
      SET _tmp=%_Str:~9,1%
      SET /A _Len=_Len+_tmp
      Set _count=0
      SET _RndAlphaNum=
      :_loop
      Set /a _count+=1
      SET _RND=%Random%
      Set /A _RND=_RND%%%_Len%
      SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
      If !_count! lss %_RNDLength% goto _loop
      Echo Password is: is !_RndAlphaNum!
      ::pause
      ::@echo %_RndAlphaNum%> %gTotal%GB_RandPass.txt
      ::for /l %%x in (1, 1, %d%) do (
      @echo %_RndAlphaNum%>> %gTotal%GB_RandPass.txt
      ::)








      share|improve this question












      share|improve this question




      share|improve this question








      edited Apr 18 at 1:30









      Jamal♦

      30.1k11114225




      30.1k11114225









      asked Apr 17 at 14:15









      Kodi4444

      61




      61

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f192294%2fbat-file-that-can-create-a-text-file-of-any-exact-size-and-it-will-be-compressio%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f192294%2fbat-file-that-can-create-a-text-file-of-any-exact-size-and-it-will-be-compressio%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?