11@ Echo Off
2- Title RandomFilePicker - v1.4.1
2+ set version = RandomFilePicker - v1.4.2
3+ Title %version%
34
45
56:: #### 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_delete = d del delete
13- set bind_review = v review
14- set bind_reload = r reload
15- set bind_randomizer =
16-
17- :: SET YOUR PREFERRED COLOR - List is on the documentation file on home page.
18- set color_code = 3
19-
20- :: This determines how many times you want the Randomizer to shuffle. Default = 250
21- Set timeout_max = 250
22-
23- :: SET YOUR SEARCH CRITERIA
24- set search_mode = 1
25- :: 1 = Images
26- :: 2 = Videos
27- :: 3 = Music
28- :: 4 = Images, Videos, Music
29- :: 5 = Every possible file type (CAUTION: Will literally open anything)
30-
31-
32- :: Image file types
33- set file_type1.1 = .png
34- set file_type1.2 = .jpg
35- set file_type1.3 = .jpeg
36- set file_type1.4 = .webp
37- :: Video file types
38- set file_type2.1 = .mp4
39- set file_type2.2 = .mkv
40- set file_type2.3 = .mov
41- set file_type2.4 = .webm
42- :: Music file types
43- set file_type3.1 = .mp3
44- set file_type3.2 = .m4a
45- set file_type3.3 = .wav
46- set file_type3.4 = .wma
7+
8+ :: CAN MANUALLY SET DIRECTORY HERE- Comment the other and vice versa
9+
10+ :: Option 1 - Viewing away from directory.
11+ :: Set directory="C:\Users\Echox\OneDrive\Pictures\All_Wallpapers"
12+
13+ :: Option 2 - Viewing within same folder/subfolders.
14+ mkdir " %~dp0 " > NUL 2 >& 1
15+
16+ :: KEY BINDS - The script can recognize if you type part of a word so caution with mistyping.
17+ set bind_delete = d del delete
18+ set bind_review = v review
19+ set bind_reload = r reload
20+ set bind_randomizer =
21+
22+ :: Toggles question on what Search Mode you want set. Default = 0-disabled, 1-enabled.
23+ set manual_mode = 1
24+
25+ :: SET YOUR PREFERRED COLOR - List is on the documentation file on home page.
26+ set color_code = 3
27+
28+ :: Determines how many times you want the Randomizer to shuffle. Default = 250
29+ Set timeout_max = 250
30+
31+ :: SET YOUR SEARCH CRITERIA
32+ set search_mode = 1
33+ :: 1 = Images
34+ :: 2 = Videos
35+ :: 3 = Music
36+ :: 4 = Images, Videos, Music
37+ :: 5 = Your preferred file type (CAUTION: Will literally open anything)
38+
39+ :: FILE TYPES - Add any file extensions you may find useful.
40+ :: Image file types
41+ set file_image = .png .jpg .jpeg .webp
42+ :: Video file types
43+ set file_video = .mp4 .mkv .mov .webm
44+ :: Music file types
45+ set file_music = .mp3 .m4a .wav .wma
46+ :: Invalid file types or keywords to save you headache on avoiding certain files. Can be left empty.
47+ set file_filter = .exe
48+
4749:: #### END OF CONFIG ####
4850
4951
5052
51- :: Titles
53+ :: #### START OF SCRIPT ####
54+ set file_all = .
55+ set file_media = %file_image% %file_video% %file_music%
56+ Color %color_code%
5257Echo .
53- Echo RandomFilePicker - v1.4.1
58+ Echo %version%
5459Echo .
5560Echo -github/bandito52
5661Echo .
57- Goto Start
62+ Echo .
63+ Echo %manual_mode% | findstr " 1" > nul && (timeout 2 > nul )
64+ Echo %manual_mode% | findstr " 1" > nul && (goto ManualQuestion) || (goto Start)
65+
5866
5967:: Step 1
6068:Start
69+ Echo %manual_mode% | findstr " 1" > nul && (CLS)
6170Color %color_code%
6271Echo .
63- Echo (Step 1/4 ) - Directory set.
72+ Echo (Step 1/3 ) - Directory set, checking... Please wait a moment .
6473Set count = 0
6574Set timeout = 0
66- Echo .
67-
68- :: Step 2
69- Echo (Step 2/4) - Checking Directory... Please wait a moment.
7075For /f %%f in ('dir " %directory% " /b /s') do set /a count += 1
7176
72- :: Step 3
77+ :: Step 2
7378:Randomizer
7479Color %color_code%
7580CLS
7681Echo .
77- Echo (Step 3/4 ) - Randomizer shuffling ... Please wait a moment.
78- echo %timeout% | findstr %timeout_max% > nul && (goto Error-TimedOut) || (echo Attempt %timeout% /%timeout_max% till Timeout...)
79- :: timeout /t 1 > nul
82+ Echo (Step 2/3 ) - Randomizer searching ... Please wait a moment.
83+ Echo %timeout% | findstr %timeout_max% > nul && (goto Error-TimedOut) || (Echo Attempt %timeout% /%timeout_max% till Timeout...)
84+ :: timeout 1 >nul
8085Set /a timeout += 1
8186Set /a randN = %random% %% %count% + 1
8287Set listN = 0
8388For /f " tokens=1* delims=:" %%I in ('dir " %directory% " /b /s^ | findstr /n /r . ^ | findstr /b " %randN% " ') do set filename = %%J
84- :check1
85- echo %search_mode% | findstr " 1" > nul && (goto Search_Mode1) || (goto check2)
86- :check2
87- echo %search_mode% | findstr " 2" > nul && (goto Search_Mode2) || (goto check3)
88- :check3
89- echo %search_mode% | findstr " 3" > nul && (goto Search_Mode3) || (goto check4)
90- :check4
91- echo %search_mode% | findstr " 4" > nul && (goto Search_Mode4) || (goto check5)
92- :check5
93- echo %search_mode% | findstr " 5" > nul && (goto Search_Mode5) || (goto Error-IncorrectNum)
89+
90+ if %search_mode% LSS 1 (goto Error-IncorrectNum)
91+ if %search_mode% GTR 5 (goto Error-IncorrectNum)
92+ Echo %search_mode% | findstr " %search_mode% " > nul && (goto Search_Mode%search_mode% ) || (goto Error-IncorrectNum)
9493
9594
9695:Search_Mode1
97- 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)
96+ Echo %filename% | findstr /i " %file_image% " > nul && (goto Review) || (goto Randomizer)
9897:Search_Mode2
99- 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)
98+ Echo %filename% | findstr /i " %file_video% " > nul && (goto Review) || (goto Randomizer)
10099:Search_Mode3
101- 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)
100+ Echo %filename% | findstr /i " %file_music% " > nul && (goto Review) || (goto Randomizer)
102101:Search_Mode4
103- 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)
102+ Echo %filename% | findstr /i " %file_media% " > nul && (goto Review) || (goto Randomizer)
104103:Search_Mode5
104+ Echo %filename% | find /i " %file_all% " > nul && (goto Review) || (goto Randomizer)
105105goto Review
106106
107- :: Step 4
107+ :: Step 3
108108:Review
109- For /f %%A in (" %filename% " ) do set filesize = %%~zA
109+ Echo %filename% | find /v " %file_all% " > nul && (goto Randomizer)
110+ Echo %filename% | findstr /i " %file_invalid% " > nul && (goto Error-InvalidFile)
111+ :: For /f %%A in ("%filename%") do set filesize=%%~zA
110112CLS
111113Start " " " %filename% "
112- Echo (Step 4/4 ) - File selected and presented.
114+ Echo (Step 3/3 ) - File selected and presented.
113115
114116:: Info Pane
115117Echo .
116118Echo Location: %filename%
119+ :: Echo %filesize%
117120Echo .
118121
119122:: Choices
@@ -129,10 +132,10 @@ Echo.
129132Set timeout = 0
130133Set choice =
131134Set /p choice = Choice:
132- echo %bind_randomizer% | find /i " %choice% " > nul && goto Randomizer
133- echo %bind_delete% | find /i " %choice% " > nul && goto Deletion
134- echo %bind_reload% | find /i " %choice% " > nul && goto Start
135- echo %bind_review% | find /i " %choice% " > nul && goto Review
135+ Echo %bind_randomizer% | find /i " %choice% " > nul && goto Randomizer
136+ Echo %bind_delete% | find /i " %choice% " > nul && goto Deletion
137+ Echo %bind_reload% | find /i " %choice% " > nul && goto Start
138+ Echo %bind_review% | find /i " %choice% " > nul && goto Review
136139goto Randomizer
137140
138141:Deletion
@@ -144,30 +147,68 @@ Echo.
144147Pause
145148Goto Randomizer
146149
150+ :ManualQuestion
151+ CLS
152+ Color e
153+ Echo Heads up! You are in manual mode.
154+ Echo .
155+ Echo Enter the Search Mode you would like:
156+ Echo .
157+ timeout 1 > nul
158+ Echo 1 = Images
159+ Echo 2 = Videos
160+ Echo 3 = Music
161+ Echo 4 = Images, Videos, Music
162+ Echo 5 = Anything not filtered. (Check config)
163+ Echo .
164+ Echo .
165+ Echo If you want to disable this warning, check Config, set manual_mode to 0.
166+ Echo %search_mode% | findstr " 5" > nul && (Echo.)
167+ Echo %search_mode% | findstr " 5" > nul && (Echo You have " 5" selected. Be warned that this will open anything such as other scripts and executables...)
168+ Set timeout = 0
169+ Set /p choice = Choice:
170+ Set search_mode = %choice%
171+ Goto Start
172+
147173
148- :: Error Codes
174+ :: #### Error Codes ####
149175
150176:Error-IncorrectNum
151177CLS
152178Color C
153- echo ### ERROR ###
154- echo Code: 400
155- echo .
156- echo Search Criteria is not Mode 1-5. CHECK CONFIG.
157- echo .
158- echo Program will close upon continuing
179+ Echo ### ERROR ###
180+ Echo Code: 400
181+ Echo .
182+ Echo Search Criteria is not Mode 1-5. CHECK CONFIG.
183+ Echo .
184+ Echo Program will close upon continuing
159185Pause
160186exit
161187
162188:Error-TimedOut
163189CLS
164190Color C
165- echo ### ERROR ###
166- echo Code: 404
167- echo .
168- echo Randomizer has timed out after %timeout_max% shuffles.
169- echo Either file type does not exist or directory is too large to find it.
170- echo .
171- echo Program will close upon continuing
191+ Echo ### ERROR ###
192+ Echo Code: 404
193+ Echo .
194+ Echo Randomizer has timed out after %timeout_max% shuffles.
195+ Echo Either file type does not exist or directory is too large to find it, try again.
196+ Echo .
197+ Echo Program will close upon continuing
198+ Pause
199+ exit
200+
201+ :Error-InvalidFile
202+ CLS
203+ Color C
204+ Echo ### ERROR ###
205+ Echo Code: 403
206+ Echo .
207+ Echo Location: %filename%
208+ Echo .
209+ Echo File is an invalid type.
210+ Echo Check config for invalid file types.
211+ Echo .
212+ Echo Program will close upon continuing
172213Pause
173214exit
0 commit comments