Advertisement
DePhoegon

MassShift - Entire Partition shifting

Dec 2nd, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.88 KB | None | 0 0
  1. @echo off
  2. set tmp=T3mp0r4ry
  3. GOTO ARGS
  4. :: Exclusions by File name.ext & by root folder at top for ease
  5. :: Execution done in SAFE Label, to allow exit /b to work properly & continue to cycle throughout the drive
  6. :SAFE
  7. set fnscr=Y
  8. IF "%fpc:~2%" == "\" (set fnsc=Y&&exit /b)
  9. IF "%fnc%" == "pagefile.sys" (set fnsc=Y&&exit /b)
  10. IF "%fnc%" == "swapfile.sys" (set fnsc=Y&&exit /b)
  11. IF "%fnc%" == "desktop.ini" (set fnsc=Y&&exit /b)
  12. IF "%fnc%" == "Thumbs.db" (set fnsc=Y&&exit /b)
  13. IF "%fnc:~-4%" == ".lnk" (set fnsc=Y&&exit /b)
  14. IF "%fnc:~-4%" == ".bat" (set fnsc=Y&&exit /b)
  15. IF "%fpc:~3,7%" == "WINDOWS" (set fnsc=Y&&exit /b)
  16. IF "%fpc:~3,7%" == "Program" (set fnsc=Y&&exit /b)
  17. IF "%fpc:~3,8%" == "Recovery" (set fnsc=Y&&exit /b)
  18. IF "%fpc:~3,1%" == "$" (set fnsc=Y&&exit /b)
  19. IF "%fpc:~3,6%" == "Config" (set fnsc=Y&&exit /b)
  20. IF "%fpc:~3,5%" == "Files" (set fnsc=Y&&exit /b)
  21. IF "%fpc:~3,25%" == "System Volume Information" (set fnsc=Y&&exit /b)
  22. IF "%fpc:~3,8%" == "OneDrive" (set fnsc=Y&&exit /b)
  23. IF "%fnsc%" == "Y" exit /b
  24. echo %fpc%%fnc% shifting
  25. IF NOT EXIST "%fpc%%csf%\" mkdir "%fpc%%csf%\"
  26. copy "%fpc%%fnc%" "%fpc%%csf%\"
  27. del /f "%fpc%%fnc%"
  28. move "%fpc%%csf%\%fnc%" "%fpc%"
  29. rmdir "%fpc%%csf%\"
  30. exit /b
  31. :ARGS
  32. ::One Time Prep and/or help arguments
  33. IF %1.==. GOTO REQU
  34. IF %1==help GOTO HLPO
  35. IF %1==drive GOTO DHE
  36. IF %1==path GOTO FHE
  37. IF %1==ex GOTO FIHE
  38. IF %1==temp GOTO CFH
  39. set dr=%1
  40. set dr=%dr:~0,1%
  41. IF %dr% LEQ 9 ( echo Letters Only for Drive Selection && GOTO ELOP )
  42. IF %2.==. GOTO REQU
  43. set pth=%2
  44. :A21
  45. IF %pth%.==. GOTO REQU
  46. IF %pth:~0,1%==/ (set pth=%pth:~1%&& GOTO A21 )
  47. IF %pth:~-1%==/ (set pth=%pth:~0,-1%&& GOTO A21 )
  48. IF %pth:~0,1%==\ (set pth=%pth:~1%&& GOTO A21 )
  49. IF %pth:~-1%==\ (set pth=%pth:~0,-1%&& GOTO A21 )
  50. IF "%pth:~0,1%" == " " (set pth=%pth:~1%&& GOTO A21 )
  51. IF "%pth:~-1%" == " " (set pth=%pth:~0,-1%&& GOTO A21 )
  52. IF %pth%==driveroot set fptc=%dr%:\
  53. IF NOT %pth%==driveroot set fptc=%dr%:\%pth%\
  54. IF %3.==. GOTO THIR
  55. IF %3==any GOTO THIR
  56. set ex=%3
  57. :A31
  58. IF %ex:~0,1%==. (set ex=%ex:~1%&& GOTO A31 )
  59. IF %ex:~0,1%==* GOTO SERR
  60. set ex=*.%ex%
  61. GOTO SFR
  62. :THIR
  63. set ex=*
  64. :SFR
  65. set csf=%4
  66. IF %4.==. set csf=%tmp%
  67. :A41
  68. IF %csf:~0,1%==/ (set csf=%csf:~1%&& GOTO A41 )
  69. IF %csf:~-1%==/ (set csf=%csf:~0,-1%&& GOTO A41 )
  70. IF %csf:~0,1%==\ (set csf=%csf:~1%&& GOTO A41 )
  71. IF %csf:~-1%==\ (set csf=%csf:~0,-1%&& GOTO A41 )
  72. IF "%csf:~0,1%" == " " (set csf=%csf:~1%&& GOTO A41 )
  73. IF "%csf:~-1%" == " " (set csf=%csf:~0,-1%&& GOTO A41 )
  74.  
  75. ::Start prep
  76. set fnsc=N
  77. set fnscr=N
  78. IF NOT EXIST %fptc% GOTO REQU
  79. %dr%:
  80. cd %fptc%
  81. for /r %%i in (%ex%) do (
  82. set fnsc=N
  83. set fnscr=N
  84. set fnc=%%~nxi
  85. set fpc=%%~dpi
  86. Call :SAFE
  87. )
  88. :REQU
  89. echo "Requires Valid Paramaters to be passed into the file as well."
  90. echo (Drive_Letter* // StartingFolder_Path* // File_Extenstion // Custom_TempFolder)
  91. echo Use ' MassShift help ' to get more info.
  92. echo Use switch command or LOWERCASE 'help'
  93. GOTO ELOP
  94. :HLPO
  95. echo Help for batch commands
  96. echo Paramater Order "(Drive_Letter* // StartingFolder_Path* // File_Extenstion // Custom_TempFolder)
  97. echo Default Hold folder for the 'Balancing' is %tmp%
  98. echo ' MassShift drive ' for Valid Drive leters
  99. echo ' MassShift path ' for Folder Path Formating
  100. echo ' MassShift ex ' for Valid inputs
  101. echo ' MassShift temp ' for Valid Temp folders
  102. GOTO ELOP
  103. :DHE
  104. echo REQUIRED
  105. echo Any Drive letter A-Z
  106. echo Formats C // C: // C:/
  107. echo No Spaces
  108. GOTO ELOP
  109. :FHE
  110. echo REQUIRED
  111. echo Spaces are allowed within the folder name, not before or after
  112. echo To start at the root of a drive, use 'driveroot' [without the ''] for StartingFolder_Path. [will skip all files on the drive root]
  113. echo Use of " " is required around the entire Folder_Path input has spaces in it. Example  "Storage Files"
  114. echo Formats Folder_Name // Folder_Name\ // \Folder_Name
  115. echo Folders May Follow Folders, must use a \ between folders.
  116. echo Can have a \ at the begining and end of each folder
  117. GOTO EFLOP
  118. :FIHE
  119. echo OPTIONAL
  120. echo No Spaces
  121. echo Must use ' any ' [without ''] for Extension place for all files while wanting to use a custom temp folder
  122. echo Defaults to wildstar for all files if not given a extension
  123. echo Formats  txt //  .txt
  124. echo no character limit on extensions
  125. :SERR
  126. echo Do NOT use regex in file extension
  127. echo leave Extension blank for wildstar
  128. GOTO ELOP
  129. :CFH
  130. echo OPTIONAL
  131. echo Will not use sub folder that currently exists
  132. echo Is a sub folder.  Not setup to transfer drives.
  133. echo Use of " " is required around the entire Folder_Path input has spaces in it. Example  "Temporary Files"
  134. echo Formats Folder_Name // Folder_Name\ // \Folder_Name
  135. echo Folders May Follow Folders, must use a \ between folders.
  136. echo Can have a \ at the begining and end of each folder
  137. GOTO ELOP
  138. :CFEE
  139. echo Temporary Folder Name exists already. Ensure %tmp% folder is not in the same folder as the files, or that you enter a Folder name that does not exist.
  140. echo %fpc%%fnc%
  141. pause
  142. GOTO ELOP
  143. :ELOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement