1+ @ Echo Off
2+ Title RandomFilePicker - Vue
3+
4+
5+ :: #### CONFIG SECTION ####
6+
7+ :: CAN MANUALLY SET DIRECTORY HERE- Comment the other and vice versa
8+ :: Set directory="C:\Users\echox\OneDrive\Pictures\All_Wallpapers"
9+ mkdir " %~dp0 " > NUL 2 >& 1
10+ :: KEY BINDS - Edit these lists to your liking
11+
12+ set bind_randomizer = 1
13+ set bind_reload = 2
14+
15+ :: SET YOUR PREFERRED COLOR - List is on the documentation file on home page.
16+ set color_code = 3
17+
18+ :: This determines how many times you want the Randomizer to shuffle. Default = 250
19+ Set timeout_max = 250
20+
21+ :: SET YOUR SEARCH CRITERIA
22+ set search_mode = 4
23+ :: 1 = Images
24+ :: 2 = Videos
25+ :: 3 = Music
26+ :: 4 = Images, Videos, Music
27+ :: 5 = Every possible file type (CAUTION: Will literally open anything)
28+
29+
30+ :: Image file types
31+ set file_type1.1 = .png
32+ set file_type1.2 = .jpg
33+ set file_type1.3 = .jpeg
34+ set file_type1.4 = .webp
35+ :: Video file types
36+ set file_type2.1 = .mp4
37+ set file_type2.2 = .mkv
38+ set file_type2.3 = .mov
39+ set file_type2.4 = .webm
40+ :: Music file types
41+ set file_type3.1 = .mp3
42+ set file_type3.2 = .m4a
43+ set file_type3.3 = .wav
44+ set file_type3.4 = .wma
45+ :: #### END OF CONFIG ####
46+
47+
48+
49+ Goto Start
50+
51+ :: Step 1
52+ :Start
53+ Color %color_code%
54+ Set count = 0
55+ Set timeout = 0
56+
57+ :: Step 2
58+ For /f %%f in ('dir " %directory% " /b /s') do set /a count += 1
59+
60+ :: Step 3
61+ :Randomizer
62+ Color %color_code%
63+ CLS
64+ echo %timeout% | findstr %timeout_max% > nul && (goto Error-Timed Out) || (echo Attempt %timeout% /%timeout_max% till Timeout...)
65+ :: timeout /t 1 > nul
66+ Set /a timeout += 1
67+ Set /a randN = %random% %% %count% + 1
68+ Set listN = 0
69+ For /f " tokens=1* delims=:" %%I in ('dir " %directory% " /b /s^ | findstr /n /r . ^ | findstr /b " %randN% " ') do set filename = %%J
70+ :check1
71+ echo %search_mode% | findstr " 1" > nul && (goto Search_Mode1) || (goto check2)
72+ :check2
73+ echo %search_mode% | findstr " 2" > nul && (goto Search_Mode2) || (goto check3)
74+ :check3
75+ echo %search_mode% | findstr " 3" > nul && (goto Search_Mode3) || (goto check4)
76+ :check4
77+ echo %search_mode% | findstr " 4" > nul && (goto Search_Mode4) || (goto check5)
78+ :check5
79+ echo %search_mode% | findstr " 5" > nul && (goto Search_Mode5) || (goto Error-IncorrectNum)
80+
81+
82+ :Search_Mode1
83+ echo %filename% | findstr /i /c:%file_type1.1% /c:%file_type1.2% /c:%file_type1.3% /c:%file_type1.4% > nul && (goto Review) || (goto Randomizer)
84+ :Search_Mode2
85+ echo %filename% | findstr /i /c:%file_type2.1% /c:%file_type2.2% /c:%file_type2.3% /c:%file_type2.4% > nul && (goto Review) || (goto Randomizer)
86+ :Search_Mode3
87+ echo %filename% | findstr /i /c:%file_type3.1% /c:%file_type3.2% /c:%file_type3.3% /c:%file_type3.4% > nul && (goto Review) || (goto Randomizer)
88+ :Search_Mode4
89+ echo %filename% | findstr /i /c:%file_type1.1% /c:%file_type1.2% /c:%file_type1.3% /c:%file_type1.4% /c:%file_type2.1% /c:%file_type2.2% /c:%file_type2.3% /c:%file_type2.4% /c:%file_type3.1% /c:%file_type3.2% /c:%file_type3.3% /c:%file_type3.4% > nul && (goto Review) || (goto Randomizer)
90+ :Search_Mode5
91+ goto Review
92+
93+ :: Step 4
94+ :Review
95+ For /f %%A in (" %filename% " ) do set filesize = %%~zA
96+ CLS
97+ Start " " " %filename% "
98+
99+ :: Info Pane
100+ Echo RandomFilePicker - Vue
101+ Echo -github/bandito52
102+ Echo .
103+
104+ :: Choices
105+ Echo How do you want to continue?
106+ Echo .
107+ Echo %bind_randomizer% = Reroll for new file.
108+ Echo %bind_reload% = Update directory if you added new files.
109+ Echo .
110+ Set timeout = 0
111+ Set choice =
112+ Set /p choice = Choice:
113+ echo %bind_randomizer% | find /i " %choice% " > nul && goto Randomizer
114+ echo %bind_reload% | find /i " %choice% " > nul && goto Start
115+ goto Randomizer
116+
117+
118+ :: Error Codes
119+
120+ :Error-IncorrectNum
121+ CLS
122+ Color C
123+ echo ### ERROR ###
124+ echo Code: 400
125+ echo .
126+ echo Search Criteria is not Mode 1-5. CHECK CONFIG.
127+ echo .
128+ echo Program will close upon continuing
129+ Pause
130+ exit
131+
132+ :Error-Timed Out
133+ CLS
134+ Color C
135+ echo ### ERROR ###
136+ echo Code: 404
137+ echo .
138+ echo Randomizer has timed out after %timeout_max% shuffles.
139+ echo Either file type does not exist or directory is too large to find it.
140+ echo .
141+ echo Program will close upon continuing
142+ Pause
143+ exit
0 commit comments