Skip to content

Commit 26e5f87

Browse files
authored
Updated Vue with v1.4.2's optimization.
1 parent 2e5810a commit 26e5f87

1 file changed

Lines changed: 128 additions & 84 deletions

File tree

source-Vue.bat

Lines changed: 128 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,187 @@
11
@Echo Off
2-
Title RandomFilePicker - Vue
2+
set version=RandomFilePicker - Vue
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_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
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_randomizer=1
18+
set bind_reload=2
19+
20+
::Toggles question on what Search Mode you want set. Default = 0-disabled, 1-enabled.
21+
set manual_mode=0
22+
23+
::SET YOUR PREFERRED COLOR - List is on the documentation file on home page.
24+
set color_code=3
25+
26+
::Determines how many times you want the Randomizer to shuffle. Default = 250
27+
Set timeout_max=250
28+
29+
::SET YOUR SEARCH CRITERIA
30+
set search_mode=4
31+
::1 = Images
32+
::2 = Videos
33+
::3 = Music
34+
::4 = Images, Videos, Music
35+
::5 = Your preferred file type (CAUTION: Will literally open anything)
36+
37+
::FILE TYPES - Add any file extensions you may find useful.
38+
::Image file types
39+
set file_image=.png .jpg .jpeg .webp
40+
::Video file types
41+
set file_video=.mp4 .mkv .mov .webm
42+
::Music file types
43+
set file_music=.mp3 .m4a .wav .wma
44+
::Invalid file types or keywords to save you headache on avoiding certain files. Can be left empty.
45+
set file_filter=.exe
46+
4547
::#### END OF CONFIG ####
4648

4749

4850

49-
Goto Start
51+
::#### START OF SCRIPT ####
52+
set file_all=.
53+
set file_media=%file_image% %file_video% %file_music%
54+
Color %color_code%
55+
Echo %manual_mode% | findstr "1" >nul && (timeout 2 >nul)
56+
Echo %manual_mode% | findstr "1" >nul && (goto ManualQuestion) || (goto Start)
57+
5058

5159
::Step 1
5260
:Start
61+
Echo %manual_mode% | findstr "1" >nul && (CLS)
5362
Color %color_code%
5463
Set count=0
5564
Set timeout=0
56-
57-
::Step 2
5865
For /f %%f in ('dir "%directory%" /b /s') do set /a count+=1
5966

60-
::Step 3
67+
::Step 2
6168
:Randomizer
6269
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
70+
Echo %timeout% | findstr %timeout_max% >nul && (goto Error-TimedOut) || (Echo Attempt %timeout%/%timeout_max% till Timeout...)
71+
::timeout 1 >nul
6672
Set /a timeout+=1
6773
Set /a randN=%random% %% %count% +1
6874
Set listN=0
6975
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)
76+
77+
if %search_mode% LSS 1 (goto Error-IncorrectNum)
78+
if %search_mode% GTR 5 (goto Error-IncorrectNum)
79+
Echo %search_mode% | findstr "%search_mode%" >nul && (goto Search_Mode%search_mode%) || (goto Error-IncorrectNum)
8080

8181

8282
: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)
83+
Echo %filename% | findstr /i "%file_image%" >nul && (goto Review) || (goto Randomizer)
8484
: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)
85+
Echo %filename% | findstr /i "%file_video%" >nul && (goto Review) || (goto Randomizer)
8686
: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)
87+
Echo %filename% | findstr /i "%file_music%" >nul && (goto Review) || (goto Randomizer)
8888
: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)
89+
Echo %filename% | findstr /i "%file_media%" >nul && (goto Review) || (goto Randomizer)
9090
:Search_Mode5
91+
Echo %filename% | find /i "%file_all%" >nul && (goto Review) || (goto Randomizer)
9192
goto Review
9293

93-
::Step 4
94+
::Step 3
9495
:Review
95-
For /f %%A in ("%filename%") do set filesize=%%~zA
96-
CLS
96+
Echo %filename% | find /v "%file_all%" >nul && (goto Randomizer)
97+
Echo %filename% | findstr /i "%file_filter%" >nul && (goto Error-InvalidFile)
98+
::For /f %%A in ("%filename%") do set filesize=%%~zA
9799
Start "" "%filename%"
98100

99101
::Info Pane
100-
Echo RandomFilePicker - Vue
102+
CLS
103+
::Echo %filesize%
104+
Echo %version%
101105
Echo -github/bandito52
102-
Echo.
103106

104107
::Choices
108+
Echo.
105109
Echo How do you want to continue?
106110
Echo.
111+
Echo OPTIONS:
112+
Echo.
107113
Echo %bind_randomizer% = Reroll for new file.
108114
Echo %bind_reload% = Update directory if you added new files.
109115
Echo.
110116
Set timeout=0
111117
Set choice=
112118
Set /p choice= Choice:
113-
echo %bind_randomizer% | find /i "%choice%" >nul && goto Randomizer
114-
echo %bind_reload% | find /i "%choice%" >nul && goto Start
119+
Echo %bind_randomizer% | find /i "%choice%" >nul && goto Randomizer
120+
Echo %bind_reload% | find /i "%choice%" >nul && goto Start
115121
goto Randomizer
116122

123+
:ManualQuestion
124+
CLS
125+
Color e
126+
Echo Heads up! You are in manual mode.
127+
Echo.
128+
Echo Enter the Search Mode you would like:
129+
Echo.
130+
timeout 1 >nul
131+
Echo 1 = Images
132+
Echo 2 = Videos
133+
Echo 3 = Music
134+
Echo 4 = Images, Videos, Music
135+
Echo 5 = Anything not filtered. (Check config)
136+
Echo.
137+
Echo.
138+
Echo If you want to disable this warning, check Config, set manual_mode to 0.
139+
Echo %search_mode% | findstr "5" >nul && (Echo.)
140+
Echo %search_mode% | findstr "5" >nul && (Echo You have "5" selected. Be warned that this will open anything such as other scripts and executables...)
141+
Set timeout=0
142+
Set /p choice= Choice:
143+
Set search_mode=%choice%
144+
Goto Start
145+
117146

118-
::Error Codes
147+
::#### Error Codes ####
119148

120149
:Error-IncorrectNum
121150
CLS
122151
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
152+
Echo ### ERROR ###
153+
Echo Code: 400
154+
Echo.
155+
Echo Search Criteria is not Mode 1-5. CHECK CONFIG.
156+
Echo.
157+
Echo Program will close upon continuing
129158
Pause
130159
exit
131160

132-
:Error-Timed Out
161+
:Error-TimedOut
133162
CLS
134163
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
164+
Echo ### ERROR ###
165+
Echo Code: 404
166+
Echo.
167+
Echo Randomizer has timed out after %timeout_max% shuffles.
168+
Echo Either file type does not exist or directory is too large to find it, try again.
169+
Echo.
170+
Echo Program will close upon continuing
142171
Pause
143-
exit
172+
exit
173+
174+
:Error-InvalidFile
175+
CLS
176+
Color C
177+
Echo ### ERROR ###
178+
Echo Code: 403
179+
Echo.
180+
Echo Location: %filename%
181+
Echo.
182+
Echo File is an invalid type.
183+
Echo Check config for invalid file types.
184+
Echo.
185+
Echo Program will close upon continuing
186+
Pause
187+
exit

0 commit comments

Comments
 (0)