Guest User

Untitled

a guest
Jul 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. @echo OFF
  2. cls
  3.  
  4. TITLE SPLIT FILE
  5.  
  6. set originalFile=%1
  7. set splitLine=%2
  8.  
  9. :: Where I'm running this script from
  10. set thisScriptPath=%~dp0
  11.  
  12. :: set to splitLine to create the initial file or wipe clean if it exists
  13. set currentLineNumber=%splitLine%
  14.  
  15. set newFileNumber=1
  16. set outputFile=%originalFile%_%newFileNumber%.txt
  17.  
  18. if "%originalFile%"=="" GOTO :ENVIRONMENTNOTSET
  19. if "%splitLine%"=="" GOTO :ENVIRONMENTNOTSET
  20.  
  21. set outputFileAndPath=%thisScriptPath%%outputDirectory%\%outputFile%
  22.  
  23.  
  24. :: Red
  25. set backgroundColor=4
  26.  
  27. :: white
  28. set foregroundColor=7
  29.  
  30. echo WORKING ...
  31. :: Set the background and foreground color to show that it is working
  32. color %backgroundColor%%foregroundColor%
  33.  
  34.  
  35. :: Look for .prt files recursively in all folders
  36. FOR /F %%i in (%originalFile%) DO CALL :SPLIT_FILE %%i
  37.  
  38. cls
  39. echo DONE... Splitting File: %originalFile%
  40.  
  41.  
  42. :: Sets the background and foreground color back to standard
  43. color 07
  44.  
  45. GOTO :QUIT
  46. ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47.  
  48.  
  49. :SPLIT_FILE
  50. set lineInFile=%*
  51.  
  52. if %currentLineNumber%==%splitLine% CALL :CREATE_NEW_FILE
  53.  
  54. set /A currentLineNumber+=1
  55.  
  56. :: Populate the new file
  57. echo %lineInFile% >> %outputFile%
  58.  
  59.  
  60. GOTO :EOF
  61.  
  62.  
  63.  
  64. :CREATEDIR
  65. set argument=%*
  66.  
  67. :: If the folder does not exist this will create it
  68. if not exist %thisScriptLocation%\%argument% md %argument%
  69.  
  70. GOTO :EOF
  71.  
  72.  
  73.  
  74. :CREATE_NEW_FILE
  75.  
  76. :: Reset line number
  77. set currentLineNumber=0
  78.  
  79. set outputFile=%originalFile%_%newFileNumber%
  80.  
  81. :: Wipe existing file out if it exists
  82. echo. > %outputFile%
  83.  
  84. :: Incriment the File number by 1
  85. set /A newFileNumber+=1
  86.  
  87. cls
  88. echo WORKING ... Creating: %outputFile%
  89.  
  90. GOTO :EOF
  91.  
  92.  
  93.  
  94. :ENVIRONMENTNOTSET
  95.  
  96. echo.
  97. echo MISSING REQUIRED ARGUMENTS
  98. echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99. echo USAGE: %~0 originalFile outputDirectory splitLine
  100. echo EXAMPLE: %~0 items.txt 6000 output
  101. echo.
  102. echo.
  103. echo YOU PROVIDED:
  104. echo.
  105. if "%originalFile%"=="" (ECHO inputFile= *MISSING*) ELSE (ECHO %originalFile%)
  106. if "%splitLine%"=="" (ECHO outputFile= *MISSING*) ELSE (ECHO %splitLine%)
  107. if "%outputDirectory%"=="" (ECHO outputFile= [OPTIONAL]) ELSE (ECHO %outputDirectory%)
  108. echo.
  109.  
  110.  
  111.  
  112. :QUIT
  113.  
  114. :: Set the Toolbar back to CMD
  115. title %comspec%
Add Comment
Please, Sign In to add comment