mirolord

случайная папка

Aug 31st, 2026
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | Cryptocurrency | 0 0
  1. ```bat
  2. @echo off
  3. setlocal EnableDelayedExpansion
  4.  
  5. set "base=%~dp0"
  6. set /a count=0
  7.  
  8. rem Считаем папки
  9. for /d %%D in ("%base%*") do (
  10. set /a count+=1
  11. set "folder[!count!]=%%~fD"
  12. )
  13.  
  14. rem Проверяем, есть ли папки
  15. if %count%==0 (
  16. echo В текущей папке нет подпапок.
  17. pause
  18. exit /b
  19. )
  20.  
  21. rem Выбираем случайную папку
  22. set /a random=%random% %% count + 1
  23.  
  24. rem Открываем её
  25. explorer "!folder[%random%]!"
  26.  
  27. endlocal
  28. ```
  29.  
Advertisement
Add Comment
Please, Sign In to add comment