Cogger

Direction-SubFolder-Creation.bat

Nov 22nd, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. if "%~1" == "" goto checkinst
  4. del %1 2>nul
  5. echo Enter subfolders to create. e.g.: sub dir\another sub dir\and more...
  6. set /p dirs=
  7. set dirs=%dirs%
  8. if "%dirs%" == "" (
  9.   echo Aborted.
  10.   pause
  11.   goto :eof
  12. )
  13. md %~dp0\%dirs%
  14. if %errorlevel% == 0 echo Subfolders successfully created.
  15. pause
  16. goto :eof
  17.  
  18. :checkinst
  19. reg query hkcr\.subdirs /v "" 2>nul >nul
  20. if %errorlevel% == 0 goto uninst
  21. choice /n /m "Subfolders Maker is not yet installed. Install it now [Y/N]?"
  22. if %errorlevel% == 2 goto :eof
  23. if %errorlevel% == 0 goto :eof
  24. reg add hkcr\.subdirs /v "" /d subdirs >nul
  25. if errorlevel 1 (
  26.   pause
  27.   goto :eof
  28. )
  29. reg add hkcr\.subdirs\shellnew /v command /d "%~f0 ""%%1""" >nul
  30. reg add hkcr\subdirs /v "" /d Subfolders >nul
  31. echo Subfolders Maker has been installed.
  32. echo Use the "New > Subfolders" right-click popup menu to create subfolders.
  33. echo Reopen Explorer window if the "Subfolders" menu item is not shown.
  34. pause
  35. goto :eof
  36.  
  37. :uninst
  38. choice /n /m "Subfolders Maker is already installed. Uninstall it now [Y/N]?"
  39. if %errorlevel% == 2 goto :eof
  40. if %errorlevel% == 0 goto :eof
  41. reg delete hkcr\.subdirs /f >nul
  42. if errorlevel 1 (
  43.   pause
  44.   goto :eof
  45. )
  46. reg delete hkcr\subdirs /f >nul
  47. echo Subfolders Maker has been uninstalled.
  48. choice /n /m "Delete this batch file too [Y/N]?"
  49. if %errorlevel% == 2 goto :eof
  50. if %errorlevel% == 0 goto :eof
  51. start "" /min cmd.exe "/c timeout 1 & del "%~f0""
Add Comment
Please, Sign In to add comment